|
-
Apr 27th, 2000, 12:05 AM
#1
Dim Hours As Integer
Dim Mins As Integer
Dim Pos As Integer
Dim myTime As String
myTime = lblCompTotal.Caption
Pos = InStr(1, myTime, ":")
Hours = Mid$(myTime, 1, Pos - 1)
Mins = Mid$(myTime, Pos + 1, Len(myTime))
Text222.Text = Hours + Mins
The error message I get is type mismatch at
Mins = Mid$(myTime, Pos + 1, Len(myTime))
Can someone tell me what I have wrong here
I'm trying to take a string of 40:15 and put the 40 in HOURS and the 14 in MINS
-
Apr 27th, 2000, 12:30 AM
#2
Fanatic Member
Do you have "40:15" in your label? It seems to work on my machine.
-
Apr 27th, 2000, 12:34 AM
#3
Addicted Member
I'm not sure if this is the problem but len(Mytime) will return a value of 5 (total length of the string), but you are telling it to start at position 4 (for your example). This puts it out to 9 characters. This may be the problem especially since the VB is trying to convert the results to an intger.
If you just want to get the rest of the string form pos + 1 just used the mid$ without the length.
Mins = mid$(myTime, Pos+1)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|