If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > run-time error '13' type mismatch

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-06-10, 18:36
Strashni Strashni is offline
Registered User
 
Join Date: Apr 2010
Posts: 3
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!
Reply With Quote
  #2 (permalink)  
Old 04-06-10, 23:59
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
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.
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Last edited by pkstormy; 04-07-10 at 00:26.
Reply With Quote
  #3 (permalink)  
Old 04-07-10, 01:42
Strashni Strashni is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 04-07-10, 04:31
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #5 (permalink)  
Old 04-07-10, 07:02
Strashni Strashni is offline
Registered User
 
Join Date: Apr 2010
Posts: 3
pkstormy thanks a lot. I fix error using '
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On