Results 1 to 3 of 3

Thread: Error Message

  1. #1
    Guest
    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

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    Do you have "40:15" in your label? It seems to work on my machine.

  3. #3
    Addicted Member
    Join Date
    Jan 2000
    Location
    Oshkosh, WI
    Posts
    163
    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
  •  



Click Here to Expand Forum to Full Width