PDA

View Full Version : Visual Basic - Help Please



CurryCricketer
June 9th, 2004, 09:00 AM
"In my place"

Hi i need some help with visual basic

I am making a time converter for a school project but when i ask it to convert a time i sometimes get the date 29/12/1899 before the time. Can any one help me get rid of this? Please. Here is the code:

Dim Hours As Integer
Dim Mins As Integer
Dim TempTimeH as Date

'AM or PM??
Hours = txtHours.Text
Mins = txtMinutes.Text

Select Case lstAMPM.Text
Case "PM"
If Hours = 12 Then
TempTimeH = TimeSerial(12, Mins, 0)
Else
TempTimeH = TimeSerial((Hours + 12), Mins, 0)
End If
Case "AM"
If Hours = 12 Then
TempTimeH = TimeSerial(0, Mins, 0)
Else
TempTimeH = TimeSerial(Hours, Mins, 0)
End If
End Select
'End AM or Pm??

lblFinTime.Caption = DateAdd("n", -(60 * 10), TempTimeH)

Thankyou Kindly
CurryCricketer

λ
June 9th, 2004, 12:10 PM
Don't crosspost.

minimalistik
June 10th, 2004, 02:27 AM
Don't crosspost.


give him a break man, geez his only got 3 posts and hes been working on it for a few days now.

λ
June 10th, 2004, 02:48 AM
give him a break man, geez his only got 3 posts and hes been working on it for a few days now.
Well yeah, I would.. but you need to tell them somehow.

Why not try a different forum? http://www.visualbasicforum.com/ looked alright..

CurryCricketer
June 10th, 2004, 07:58 AM
Thanks for the forum mate

defcon4
June 10th, 2004, 03:30 PM
try wrapping your hours and minutes-
.text is a string, functions are usually type cast and are looking for integers - plus you type casted hours and minutes as integers but are setting them to strings
Hours = cInt(txtHours.text) - same for minutes

you can also concat a string and wrap w/ cDate() to perform date operations.