VBA script , how can i write this code better? Run time error 13 , Type mismatch

cymek

I know I have a problem with

IPROUTER = (Left(IP, 11)) & ((Right(IP, 3)) + 5)

Im new at vba , how i should write this line to not get titled error?

'''VBA
Dim ID As String
  Dim IP As String
  Dim IPROUTER As String

  ID = Mid(olItem.Subject, 20, 9)
  IP = Right(olItem.Body, 14)

   IPROUTER = (Left(IP, 11)) & ((Right(IP, 3)) + 5)

   With objFile
    .WriteLine "START " & Chr(34) & ID & Chr(34) & " ping" & IP & " -t"
'''
cymek

Thanks for the reply. It didn't help but I figured it out in a diffrent way. I just convert string to int. Code of my example below:

Dim ID As String
Dim IP As String
Dim IPROUTER As String
Dim ok As String
Dim okI As Integer


ID = Mid(olItem.Subject, 20, 9)
IP = Right(olItem.Body, 14)



 IPROUTER = (Left(IP, 12))

 ok = Mid(IP, 13, 3)
 okI = CInt(ok)





 With objFile
  .WriteLine "START " & Chr(34) & ID & Chr(34) & " ping " & IP & " -t"
  .WriteLine "START " & Chr(34) & ID & Chr(34) & " ping " & IPROUTER & okI + 5 & " -t" 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Excel VBA code throwing Run-time error '13': Type mismatch error

Excel VBA Run-time error Type mismatch 13

Excel VBA Run-time error '13': Type mismatch

VBA in Excel Run Time Error 13: Type Mismatch

VBA Run-time error '13': Type mismatch

Excel VBA - Run-time error '13': Type mismatch

run time error 13: type mismatch everytime i run my code

Run-time error '13': Type mismatch in SQL code

How to fix run time error 13 type mismatch

Run-time error '13' Type mismatch: If Or

Type Mismatch Run-Time error 13

Assigning 2 Time variables to time values in 2 Cells using VBA script throws type mismatch error 13

Excel 2016, VBA, Run-time error 13: type mismatch error

Updating exchange rates - VBA - Run-time error 13 Type mismatch

Got "Run-time error '13': Type mismatch" when trying to detect if a Userform is closed - in Excel VBA

Application.Wait and Excel VBA Run-time error '13' Type mismatch

Excel VBA Pivot Cache Type Mismatch Run-Time Error '13'

'Run-time error 13' for a dynamic range with variables in VBA. Data type mismatch

Excel VBA, UnHiding Sheets in array, Run-time error '13': Type mismatch

VBA Scripting.dictionary run-time error '13' type mismatch

Run-time error 13: Type Mismatch in VBA when trying to call function from another workbook

Run Time Error '13: Type Mismatch when comparing Dates - EXCEL VBA

Getting Run-time error '13': Type mismatch when I run following macro

run time 13 type mismatch

Why am I getting a" Run time Error '13': Type Mismatch" error message?

Working DLL code fails with Run-time error 13: Type mismatch when debugging

I get error 13 type mismatch vba when run another micro

VBA Error 13 Type Mismatch

Run-time Error '13': Type Mismatch when I clear cell contents