Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2010
    Posts
    3

    Unanswered: run-time error '13' type mismatch

    Hi,
    When i press one button on my program, i got this error. run-time error '13' type mismatch

    And i go debug, and it mark me this line:
    Code:
    Private Sub Timer1_Timer()
    Winsock1.SendData Chr(Len(Text1) + Len(Text2) + 14) & Chr(&H0) & Chr(&HA) & Chr(&H2) & Chr(&H0) & Chr(&HD6) & Chr(&H2) & Chr(&H0) & Chr(Hex2Dec(Right(Hex(w1acc), 2))) & Chr(Hex2Dec(Right(Left(Hex(w1acc), 3), 2))) & Chr(Hex2Dec(Left(Hex(w1acc), 1))) & Chr(&H0) & Chr(Len(Text1)) & Chr(&H0) & Text1 & Chr(Len(Text2)) & Chr(&H0) & Text2
    stat "login packet sent..."
    Timer1.Enabled = False
    Timer2.Enabled = True
    End Sub

    Help please!

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I have no idea what:

    Winsock1.SendData Chr(Len(Text1) + Len(Text2) + 14) & Chr(&H0) & Chr(&HA) & Chr(&H2) & Chr(&H0) & Chr(&HD6) & Chr(&H2) & Chr(&H0) & Chr(Hex2Dec(Right(Hex(w1acc), 2))) & Chr(Hex2Dec(Right(Left(Hex(w1acc), 3), 2))) & Chr(Hex2Dec(Left(Hex(w1acc), 1))) & Chr(&H0) & Chr(Len(Text1)) & Chr(&H0) & Text1 & Chr(Len(Text2)) & Chr(&H0) & Text2

    does but the error you're getting most likely has to do with some kind of character type mismatch somewhere within that line. Have you tried putting in syntax like: " & Chr(XXX) & ". Sometimes using the double-quote identifier (or single-quote) solves the issue.

    I might recommend adding in a few msgbox code such as:

    msgbox Chr(Len(Text1))

    or perhaps dimensioning variables...

    Dim Variable1 as string
    Variable1 = Chr(Len(Text1))
    msgbox "Variable1 = " & Variable1
    Dim Variable2 as variant
    Variable2 = Chr(&H0)
    msgbox "Variable2 = " & Variable2
    Dim Variable3 as variant
    Variable3 = Chr(Len(Text1) + Len(Text2) + 14)
    msgbox "Variable3 = " & Variable3


    and then use that in your winsock1 code. I'd break it apart to try and find the mismatch. What are you ultimately trying to accomplish with this code? It seems to me that there's either an easier way or this is the wrong forum for this question (or for me personally to answer). I haven't seen code like Hex2Dec(Right(Hex(w1acc),2) in vba but it reminds me of assembly language coding.

    or you could try:
    Dim Var1 as variant
    Var1 = Chr(Len(Text1) + Len(Text2) + 14) & Chr(&H0) & Chr(&HA) & Chr(&H2) & Chr(&H0) & Chr(&HD6) & Chr(&H2) & Chr(&H0) & Chr(Hex2Dec(Right(Hex(w1acc), 2))) & Chr(Hex2Dec(Right(Left(Hex(w1acc), 3), 2))) & Chr(Hex2Dec(Left(Hex(w1acc), 1))) & Chr(&H0) & Chr(Len(Text1)) & Chr(&H0) & Text1 & Chr(Len(Text2)) & Chr(&H0) & Text2

    msgbox Var1


    I have to admit, I'm lost here with what you're trying to accomplish but I am curious.
    Last edited by pkstormy; 04-07-10 at 01:26.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Apr 2010
    Posts
    3
    I appreciate this a lot. I tried your codes but unfortunately it show same error. I forgot to mention i'm using vb6.0
    And this would be some tool for MMORPG, so it will send packets, and it need that hexcode.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    OK so if you are using VB6 why did you not consider posting in the VB forum rather than the MS Access forum?

    as PK stormy says a Type 13 error usually means you have a wrong datatype for the specified item
    usually it means you have an alphanumeric where you should have a numeric, or a date instead of anything else and so on.

    if i were you i'd put a watch on the line that is reporting the error and read what is actually being executed
    you could use a msgbox to display it if you are not certain how to set a watch... put the msgbox statement before the winsock call, again as PK stormy says.

    its actually a very good technique in my books to assign the results of such a statement to a variable before using it in something like this or as SQL.
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Apr 2010
    Posts
    3
    pkstormy thanks a lot. I fix error using '

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •