Getting Run Time Error 13 Typy Mismatch
this coding is of EXE file of VB programing
can any 1 sold this coding for me ???
please help me

here is full coding :-

Dim serverid, serverport, serverip, agentid, lsip, lsport As Integer
Dim zonelist() As String
Dim zonecount As Integer
Dim clientinfo() As String
Dim clientpreparedinfo() As String
Dim LS_preparedcount As Integer
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Dim Tempcharpacket As String

Private Sub Command1_Click()
m = MsgBox("Are you sure you want to exit?", vbYesNo, "Zone Agent")
If m = vbYes Then End
End Sub

Private Sub Form_Load()
serverid = m1.GetINISetting("STARTUP", "SERVERID" & i, App.Path & "/svrinfo.ini")
serverport = m1.GetINISetting("STARTUP", "PORT" & i, App.Path & "/svrinfo.ini")
serverip = m1.GetINISetting("STARTUP", "IP" & i, App.Path & "/svrinfo.ini")
agentid = m1.GetINISetting("STARTUP", "AGENTID" & i, App.Path & "/svrinfo.ini")
lblserverid = serverid
lblagentid = agentid
lblzoneport = serverport
lsip = m1.GetINISetting("LOGINSERVER", "IP", App.Path & "/svrinfo.ini")
lsport = m1.GetINISetting("LOGINSERVER", "PORT", App.Path & "/svrinfo.ini")
zonecount = m1.GetINISetting("ZONESERVER", "COUNT", App.Path & "/svrinfo.ini")
ReDim zonelist(zonecount, 3) As String

For i = 0 To zonecount - 1
tempid = m1.GetINISetting("ZONESERVER", "ID" & i, App.Path & "/svrinfo.ini")
tempip = m1.GetINISetting("ZONESERVER", "IP" & i, App.Path & "/svrinfo.ini")
tempport = m1.GetINISetting("ZONESERVER", "PORT" & i, App.Path & "/svrinfo.ini")
If Not tempid = 0 Then Load sock_zone(tempid)
sock_zone(tempid).Protocol = sckTCPProtocol
sock_zone(tempid).RemoteHost = tempip
sock_zone(tempid).RemotePort = tempport
sock_zone(tempid).Connect
zonelist(i, 0) = tempid
zonelist(i, 1) = tempip
zonelist(i, 2) = tempport
combozoneiostatus.AddItem (tempip & ":" & tempport & ":" & tempid)
DoEvents
Next i
combozoneiostatus.ListIndex = 0
sock_LS.Protocol = sckTCPProtocol
sock_LS.RemoteHost = lsip
sock_LS.RemotePort = lsport
sock_LS.Connect
DoEvents
Call refreshzonestatus
ReDim clientpreparedinfo(1, 4) As String
ReDim clientinfo(1, 5) As String
sock_client(0).Protocol = sckTCPProtocol
sock_client(0).LocalPort = serverport
Load sock_client(1)
End Sub

Private Sub Form_Unload(Cancel As Integer)
m = MsgBox("Are you sure you want to exit?", vbYesNo, "Zone Agent")
If m = vbYes Then Cancel = 0 Else Cancel = 1
End Sub



Private Sub sock_client_Close(Index As Integer)
sock_client(Index).Close
Debug.Print "Client CLOSE DC"
Call SendDctoLS(clientinfo(Index, 0))
End Sub

Private Sub sock_client_ConnectionRequest(Index As Integer, ByVal requestID As Long)
Dim sock_index As Integer
sock_index = Getfreesock
sock_client(sock_index).Close
sock_client(0).Close
sock_client(sock_index).Accept requestID
Debug.Print "Client connected after loginserver"
If LS_preparedcount <> 0 Then LS_preparedcount = LS_preparedcount - 1
lblpreparedconnectioncount.Caption = LS_preparedcount
End Sub

Private Sub sock_client_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim strdata As String
sock_client(Index).GetData strdata
Dim temppacket, splitpacket As String
temppacket = strdata
Do Until temppacket = ""
splitpacket = Mid(temppacket, 1, reverseuid(Mid(temppacket, 1, 4)))
    If Len(splitpacket) < 10 Then
    sock_client(Index).Close
    Else
    If Len(splitpacket) = 56 Then

        packetuid = Mid(splitpacket, 5, 4)
            For i = 0 To UBound(clientpreparedinfo)
                If clientpreparedinfo(i, 0) = packetuid Then
                Debug.Print "Entered Client storage to store - " & Index
                clientpreparedinfo(i, 0) = ""
                clientinfo(Index, 0) = Index
                clientinfo(Index, 1) = Mid(splitpacket, 5, 4)
                clientinfo(Index, 2) = trimgameid(Mid(splitpacket, 15, 12))
                clientinfo(Index, 3) = "1" ' Zone login
                clientinfo(Index, 4) = "255"
                Exit For
                End If
            Next i
        zonelog.Text = zonelog.Text & clientinfo(Index, 2) & " (" & sock_client(Index).RemoteHost & ") User Joined" & vbCrLf
        Dim lssafepacket As String
        lssafepacket = Chr(0) & Chr(0) & Chr(0) & clientinfo(Index, 1) & Chr(2) & Chr(227) & clientinfo(Index, 2)
            For pp = 1 To 21 - Len(clientinfo(Index, 2))
            lssafepacket = lssafepacket & Chr(0)
            Next pp
        lssafepacket = Chr(Len(lssafepacket) + 1) & lssafepacket
        If sock_LS.State = 7 Then sock_LS.SendData lssafepacket

        Dim acountchar As String
        acountchar = Chr(0) & Chr(0) & Chr(0) & clientinfo(Index, 1)
        acountchar = acountchar & Chr(1) & Chr(225) & clientinfo(Index, 2)
        spacecount = 15 - Len(clientinfo(Index, 2))
            For i = 1 To 28 + spacecounts
            acountchar = acountchar & Chr(0)
            Next i
        acountchar = acountchar & sock_client(Index).RemoteHost
        spacecount = 16 - Len(sock_client(Index).RemoteHost)
            For i = 1 To 145 - Len(acountchar) + spacecount
            acountchar = acountchar & Chr(0)
            Next i
        acountchar = Chr(Len(acountchar) + 1) & acountchar
        sock_zone(clientinfo(Index, 4)).SendData acountchar
    Else

    If Len(splitpacket) = 12 Then
        Dim dcpacket As String
        dcpacket = splitpacket
        dcpacket = Mid(dcpacket, 1, 4) & clientinfo(Index, 1) & Mid(dcpacket, 9)
        If sock_zone(clientinfo(Index, 4)).State = 7 Then sock_zone(clientinfo(Index, 4)).SendData dcpacket
    Else
    splitpacket = Mid(splitpacket, 1, 4) & clientinfo(Index, 1) & Mid(splitpacket, 9)
    sock_zone(clientinfo(Index, 4)).SendData splitpacket
    End If
    End If
    End If
temppacket = Mid(temppacket, reverseuid(Mid(temppacket, 1, 4)) + 1)
Loop
End Sub

Private Sub sock_client_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Debug.Print "Client error DC -" & Number & " - " & Description
sock_client(Index).Close
Debug.Print "Closed"
Call SendDctoLS(clientinfo(Index, 0))
End Sub

Private Sub sock_zone_Close(Index As Integer)
sock_zone(Index).Close
Call refreshzonestatus
End Sub

Private Sub sock_zone_Connect(Index As Integer)
If sock_zone(Index).State = 7 Then sock_zone(Index).SendData (Chr(11) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(1) & Chr(224) & Chr(agentid))
DoEvents
DoEvents
zonelog = zonelog & vbclrf & "Zone server (" & Index & ") Connected"
Call refreshzonestatus
End Sub

Private Sub sock_zone_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim strdata As String
sock_zone(Index).GetData strdata
Dim temppacket, splitpacket As String
temppacket = strdata
Do Until temppacket = ""
splitpacket = Mid(temppacket, 1, reverseuid(Mid(temppacket, 1, 4)))
   If Len(splitpacket) = 952 Then
        sockid = Getsockidfromuid(Mid(splitpacket, 5, 4))
        If sock_client(sockid).State = 7 Then sock_client(sockid).SendData splitpacket
    Else
    If Len(splitpacket) = 11 Then
        sockid = Getsockidfromuid(Mid(splitpacket, 5, 4))
        Dim prevzone As String
        If Mid(splitpacket, 5, 4) = clientinfo(sockid, 1) Then prevzone = clientinfo(sockid, 4): clientinfo(sockid, 4) = Asc(Mid(splitpacket, 11, 1))
        zonelog.Text = zonelog.Text & clientinfo(sockid, 2) & " user zone changed " & prevzone & " -> " & clientinfo(sockid, 4) & vbCrLf
    Else
    sockid = Getsockidfromuid(Mid(splitpacket, 5, 4))
        If sock_client(sockid).State = 7 Then sock_client(sockid).SendData splitpacket
    End If

    End If
temppacket = Mid(temppacket, reverseuid(Mid(temppacket, 1, 4)) + 1)
Loop
End Sub

Private Sub sock_zone_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
sock_zone(Index).Close
Call refreshzonestatus
End Sub

Private Sub sock_LS_Close()
sock_LS.Close
lbllssockstatus.Caption = "Login Server : Disconnected"
sock_LS.RemoteHost = lsip
sock_LS.RemotePort = lsport
sock_LS.Connect
End Sub

Private Sub sock_LS_Connect()
If sock_LS.State = 7 Then
packet = Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(2) & Chr(224) & Chr(serverid) & Chr(agentid)
packet = packet & serverip
For i = 1 To 16 - Len(serverip)
packet = packet & Chr(0)
Next i
portpart2 = Mid(Hex(serverport), 1, 2)
If Len(Hex(lsport)) > 2 Then
portpart1 = Mid(Hex(serverport), 3)
If Len(portpart1) = 1 Then portpart1 = "0" & portpart1
Else
portpart1 = "00"
End If
packet = packet & Chr(Val("&H" & portpart1)) & Chr(Val("&H" & portpart2)) & Chr(0) & Chr(0)
packet = Chr(Len(packet) + 1) & packet
sock_LS.SendData packet
lbllssockstatus.Caption = "Login Server : Connected"
End If

End Sub

Private Sub sock_LS_DataArrival(ByVal bytesTotal As Long)
Dim strdata As String
sock_LS.GetData strdata
If strdata = "" Then Exit Sub
If Asc(Mid(strdata, 1, 1)) = Len(strdata) Then
    If Asc(Mid(strdata, 1, 1)) = 40 Then
    Dim tempuid, tempid
    tempuid = Mid(strdata, 5, 4)
    tempid = trimgameid(Mid(strdata, 11, 12))

    For i = 0 To UBound(clientpreparedinfo)
        If clientpreparedinfo(i, 0) = "" Then
        Debug.Print "Client prepared of Id - " & i
        clientpreparedinfo(i, o) = tempuid
        clientpreparedinfo(i, 1) = tempid
        clientpreparedinfo(i, 2) = 0
        clientpreparedinfo(i, 3) = timeGetTime
        zonelog.Text = zonelog.Text & "<LC> UID = " & reverseuid(tempuid) & " " & tempid & " Prepared" & vbCrLf
        LS_preparedcount = LS_preparedcount + 1
        lblpreparedconnectioncount.Caption = LS_preparedcount
        sock_client(0).Listen ' Open Zone sock if prepared until connected
        Exit For
        Else
        newslot = UBound(clientpreparedinfo) + 1
        Dim temparr() As String
        ReDim temparr(UBound(clientpreparedinfo), 4) As String
        For m = 0 To UBound(clientpreparedinfo, 1)
            For n = 0 To UBound(clientpreparedinfo, 2)
            temparr(m, n) = clientpreparedinfo(m, n)
            Next n
        Next m
        ReDim clientpreparedinfo(newslot, 4) As String

        For m = 0 To UBound(temparr, 1)
            For n = 0 To UBound(temparr, 2)
            clientpreparedinfo(m, n) = temparr(m, n)
            Next n
        Next m

        clientpreparedinfo(newslot, o) = tempuid
        clientpreparedinfo(newslot, 1) = tempid
        clientpreparedinfo(newslot, 2) = 0
        clientpreparedinfo(newslot, 3) = timeGetTime
        zonelog = zonelog & "<LC> UID = " & reverseuid(tempuid) & " " & tempid & " Prepared" & vbCrLf
        LS_preparedcount = LS_preparedcount + 1
        lblpreparedconnectioncount.Caption = LS_preparedcount
        sock_client(0).Listen ' Open Zone sock if prepared until connected
        Exit For
        End If
    Next i
End If
End If
End Sub

Private Sub sock_LS_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
sock_LS.Close
lbllssockstatus.Caption = "Login Server : Disconnected"
sock_LS.RemoteHost = lsip
sock_LS.RemotePort = lsport
sock_LS.Connect
End Sub

Private Sub zonecheck_Timer()
For i = 0 To UBound(zonelist) - 1
If sock_zone(zonelist(i, 0)).State <> 7 Then
sock_zone(zonelist(i, 0)).Close
zonelog.Text = zonelog.Text & "Zone server (" & zonelist(i, 0) & ") Disconnected" & vbCrLf
sock_zone(zonelist(i, 0)).Protocol = sckTCPProtocol
sock_zone(zonelist(i, 0)).RemoteHost = zonelist(i, 1)
sock_zone(zonelist(i, 0)).RemotePort = zonelist(i, 2)
sock_zone(zonelist(i, 0)).Connect
DoEvents
Else
End If
Next i
If sock_LS.State <> 7 Then
sock_LS.Close
zonelog.Text = zonelog.Text & "Login server Disconnected" & vbCrLf
sock_LS.Protocol = sckTCPProtocol
sock_LS.RemoteHost = lsip
sock_LS.RemotePort = lsport
sock_LS.Connect
DoEvents
End If
End Sub

Public Sub refreshzonestatus()
Dim zoneconnectedcount As Integer
zoneconnectedcount = 0
lstzone.Clear
For i = 0 To UBound(zonelist) - 1
If sock_zone(zonelist(i, 0)).State <> 7 Then
lstzone.AddItem (zonelist(i, 1) & ":" & zonelist(i, 2) & ":" & zonelist(i, 0) & " Disconnected")
Else
lstzone.AddItem (zonelist(i, 1) & ":" & zonelist(i, 2) & ":" & zonelist(i, 0) & " Connected")
zoneconnectedcount = zoneconnectedcount + 1
End If
Next i
lstzone.Refresh
lblconnectedzonecount = zoneconnectedcount
End Sub

Private Sub lsreporter_Timer()
If sock_LS.State = 7 Then
packet = Chr(16) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(2) & Chr(225) & Chr(curplayercount) & Chr(0) & Chr(0) & Chr(0) & Chr(zonecount) & Chr(zonecount)
sock_LS.SendData packet
Else
sock_LS.Close
lbllssockstatus.Caption = "Login Server : Disconnected"
sock_LS.RemoteHost = lsip
sock_LS.RemotePort = lsport
sock_LS.Connect
End If
If LS_preparedcount > 0 Then
    For i = 0 To UBound(clientpreparedinfo)
    If clientpreparedinfo(i, 2) = "" And clientpreparedinfo(i, 3) <> "" Then
        If timeGetTime - clientpreparedinfo(i, 3) > 6000 Then
         packet = ""
        packet = Chr(0) & Chr(0) & Chr(0) & clientpreparedinfo(i, 0) & Chr(2) & Chr(226) & Chr(0) & clientpreparedinfo(i, 1)
        For p = 1 To 21 - Len(clientpreparedinfo(i, 1))
        packet = packet & Chr(0)
        Next p
        Dim yy, mm, dd, hh, min, sec As Integer
        yy = Year(Date)
        mm = Month(Date)
        dd = Day(Date)
        hh = Hour(Time)
        min = Minute(Time)
        sec = Second(Time)
        If Len(mm) = 1 Then mm = "0" & mm
        If Len(dd) = 1 Then dd = "0" & dd
        If Len(hh) = 1 Then hh = "0" & hh
        If Len(min) = 1 Then min = "0" & min
        If Len(sec) = 1 Then sec = "0" & sec
        timedata = yy & mm & dd & Chr(0) & hh & min & sec
        packet = packet & timedata & Chr(0)
        packet = Chr(Len(packet) + 1) & packet
        Debug.Print Len(packet)
        sock_LS.SendData packet
        zonelog.Text = zonelog.Text & "<LC> UID = " & reverseuid(clientpreparedinfo(i, 0)) & " " & clientpreparedinfo(i, 1) & " user not joined" & vbCrLf
        clientpreparedinfo(i, 0) = ""
        clientpreparedinfo(i, 1) = ""
        clientpreparedinfo(i, 2) = 0
        clientpreparedinfo(i, 3) = ""
        Debug.Print "Closed ID " & Index
        LS_preparedcount = LS_preparedcount - 1
        lblpreparedconnectioncount.Caption = LS_preparedcount
        End If
    End If
    Next i
End If

End Sub


Public Function Addzero(ByVal data As String, ByRef numberofzero As Integer) As String
Dim tempdata
tempdata = data
For i = 1 To numberofzero
tempdata = tempdata & Chr(0)
Next i
Addzero = tempdata
End Function

Public Function reverseuid(ByRef data) As Integer
Dim tempdata
For i = 4 To 1 Step -1
hexval = Hex(Asc(Mid(data, i, 1)))
If Len(hexval) = 1 Then hexval = "0" & hexval

tempdata = tempdata & hexval
reverseuid = Val("&h" & tempdata)
Next i

End Function

Public Function trimgameid(ByRef id As String) As String
pp = ""
i = 1
pp = Mid(id, i, 1)
Do Until pp = Chr(0)
trimgameid = trimgameid & pp
i = i + 1
pp = Mid(id, i, 1)
Loop
End Function

Public Function Getfreesock() As Integer
Dim temp_var As Integer
For i = 1 To sock_client.Count - 1
If sock_client(i).State <> 7 And sock_client(i).State <> 0 Then
sock_client(i).Close
DoEvents
Getfreesock = i
GoTo exx
Else
If sock_client(i).State = 0 Then
Getfreesock = i
GoTo exx
End If
End If
Next i
temp_var = sock_client.UBound + 1
newslot = temp_var
        Dim temparr() As String
        ReDim temparr(UBound(clientinfo), 5) As String
        For i = 0 To UBound(clientinfo, 1)
            For j = 0 To UBound(clientinfo, 2)
            temparr(i, j) = clientinfo(i, j)
            Next j
        Next i
        ReDim clientinfo(newslot, 5) As String

        For i = 0 To UBound(temparr, 1)
            For j = 0 To UBound(temparr, 2)
            clientinfo(i, j) = temparr(i, j)
            Next j
        Next i
temp_var = sock_client.UBound + 1
Load sock_client(temp_var)
Getfreesock = temp_var
exx:
End Function

Public Function Getsockidfromuid(ByRef UID As String) As Integer
For i = 0 To UBound(clientinfo)
    If clientinfo(i, 1) = UID Then
    Getsockidfromuid = clientinfo(i, 0)
    Exit Function
    End If
Next i
Getsockidfromuid = 0
End Function

Public Function SendDctoLS(ByRef clientid As String)
packet = ""
        packet = Chr(0) & Chr(0) & Chr(0) & clientinfo(clientid, 1) & Chr(2) & Chr(226) & Chr(0) & clientinfo(clientid, 2)
        For p = 1 To 21 - Len(clientinfo(clientid, 1))
        packet = packet & Chr(0)
        Next p
        Dim yy, mm, dd, hh, min, sec As Integer
        yy = Year(Date)
        mm = Month(Date)
        dd = Day(Date)
        hh = Hour(Time)
        min = Minute(Time)
        sec = Second(Time)
        If Len(mm) = 1 Then mm = "0" & mm
        If Len(dd) = 1 Then dd = "0" & dd
        If Len(hh) = 1 Then hh = "0" & hh
        If Len(min) = 1 Then min = "0" & min
        If Len(sec) = 1 Then sec = "0" & sec
        timedata = yy & mm & dd & Chr(0) & hh & min & sec
        packet = packet & timedata & Chr(0)
        packet = Chr(Len(packet) + 1) & packet
        Debug.Print Len(packet)
        sock_LS.SendData packet
        zonelog.Text = zonelog.Text & "<LC> UID = " & reverseuid(clientinfo(clientid, 1)) & " " & clientinfo(clientid, 2) & " user not joined" & vbCrLf
End Function

Public Sub temptestingFormload()
Dim spl() As String
Dim packet As String
Text1.Text = Replace(Text1, Chr(13) & Chr(10), "")
spl = Split(Text1, " ")
For p = 0 To UBound(spl)
packet = packet & Chr(spl(p))
Next p
Tempcharpacket = packet
End Sub

Almost 500 lines of code and you couldn't even bother to tell us what line was throwing the error? Not cool.

Please Specify where the error , occured for us to help you faster .
**Type Mismatch Occur when you combine to different variable type.
EXAMPLE :

Dim sum as String
Dim num1,num2 As Integer

num1 = 2
num2 = 2

sum = num1 + num 2 'This Line Will Cause You A type Mismatch.

Please check your variables **

here error is cming :-

Public Sub refreshzonestatus()
Dim zoneconnectedcount As String
zoneconnectedcount = 0
lstzone.Clear
For i = 0 To UBound(zonelist) - 1
If sock_zone(zonelist(i, 0)).State <> 7 Then 'This Line Giving MSG Type Mismatch 13 While Runing From VB 6'
318 line no.

check in above coding

And Let me ask u guyzz that.. @ some places in above code Chr(227),Chr(226) is there soo i need to ask that should i have to make it 255??

You are using a string to index into sock_zone. zonelist is String array therefore the result is a string. You have to index sock_zone with an integer.

Something like this might work:

For i = 0 To UBound(zonelist) - 1
If sock_zone(Val(zonelis(i,0))).State <> 7 Then
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.