Convert Visual Basic to Visual C++
-
Hi everyone What I have is a vb program that I am converting to visual C++ iv done most of the convert but am having a problem with this one. All I want to do is when my VC++ program runs that it show the current Month Day Year in seperate boxes here is the vb code. Public Sub today() 'Get today's date from system Dim currentdate, tempDay, tempMonth, tempYear As String Dim tempDate As String Dim location, StrLen As Integer Dim convert_month As String tempDate = Date$ tempMonth = Month(CDate(tempDate)) tempDay = Day(CDate(tempDate)) tempYear = Year(CDate(tempDate)) currentdate = tempMonth & "/" & tempDay & "/" & tempYear StrLen = Len(currentdate) location = InStr(currentdate, "/") txtMonth.Text = Left(currentdate, location - 1) convert_month = Convert_Date_Int2Str(txtMonth.Text) txtMonth.Text = convert_month currentdate = Right(currentdate, StrLen - location) location = InStr(currentdate, "/") txtDay.Text = Left(currentdate, location - 1) currentdate = Right(currentdate, 2) If (CInt(currentdate) < 90) Then txtyear.Text = "20" & currentdate Else txtyear.Text = "19" & currentdate End If ' End Sub any help is appreciated :omg:
-
Hi everyone What I have is a vb program that I am converting to visual C++ iv done most of the convert but am having a problem with this one. All I want to do is when my VC++ program runs that it show the current Month Day Year in seperate boxes here is the vb code. Public Sub today() 'Get today's date from system Dim currentdate, tempDay, tempMonth, tempYear As String Dim tempDate As String Dim location, StrLen As Integer Dim convert_month As String tempDate = Date$ tempMonth = Month(CDate(tempDate)) tempDay = Day(CDate(tempDate)) tempYear = Year(CDate(tempDate)) currentdate = tempMonth & "/" & tempDay & "/" & tempYear StrLen = Len(currentdate) location = InStr(currentdate, "/") txtMonth.Text = Left(currentdate, location - 1) convert_month = Convert_Date_Int2Str(txtMonth.Text) txtMonth.Text = convert_month currentdate = Right(currentdate, StrLen - location) location = InStr(currentdate, "/") txtDay.Text = Left(currentdate, location - 1) currentdate = Right(currentdate, 2) If (CInt(currentdate) < 90) Then txtyear.Text = "20" & currentdate Else txtyear.Text = "19" & currentdate End If ' End Sub any help is appreciated :omg:
If I understand this correctly, you just want to grab the current time and display it in edit boxes. To display the entire date in a single box: (editcontrolstring is the CString variable associated with the edit box.)
CTime tDate = CTime::GetCurrentTime(); CString strDate = tDate.Format( "%B %d, %Y" );//This will give you month day, year _editcontrolstring_ = strDate;
Now, to break it down a little more, you can do something like this:CTime tDate = CTime::GetCurrentTime(); CString strDate = tDate.Format( "%B" );//This gives the month _editcontrolmonthstring_ = strDate; strDate = tDate.Format( "%d" );//This gives the day _editcontroldaystring_ = strDate;
And so on.