-
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
-
Do you have "40:15" in your label? It seems to work on my machine.
-
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)