dev00790
11-03-2012, 02:27 PM
Hi I'm getting a runtime error in the code below.
Please advise.
Option Explicit
Dim i As Integer
Dim sAscii
Dim j As Integer
Dim k As Integer
Dim str As String
Dim AscEncode_result As String
Sub get_ascii_codes2()
For k = 2 To 1037
str = Cells(k, 1).Value
'str here is: "J-_c+w.+zomT6Y!2bsC-H8qlv_L+:brxrr!h,U3I+3Z.-Gs_dTZ5L&1bsspo,ffb9Q"
i = 1
For j = 2 To 350
Debug.Print str
Debug.Print i
Debug.Print j
Debug.Print k
'get run time error 5 in below line
'k=2, j=35, i=34
'str = "r!h,U3I+3Z.-Gs_dTZ5L&1bsspo,ffb9Q"
Cells(k, j).Value = CStr(Asc(Mid(str, i, 1)))
If Len(str) > 1 Then
str = Right(str, Len(str) - 1)
Else
MsgBox ("Value of str is now " & str & " for k of " & k)
End If
i = i + 1
Next j
Next k
End Sub
Please advise.
Option Explicit
Dim i As Integer
Dim sAscii
Dim j As Integer
Dim k As Integer
Dim str As String
Dim AscEncode_result As String
Sub get_ascii_codes2()
For k = 2 To 1037
str = Cells(k, 1).Value
'str here is: "J-_c+w.+zomT6Y!2bsC-H8qlv_L+:brxrr!h,U3I+3Z.-Gs_dTZ5L&1bsspo,ffb9Q"
i = 1
For j = 2 To 350
Debug.Print str
Debug.Print i
Debug.Print j
Debug.Print k
'get run time error 5 in below line
'k=2, j=35, i=34
'str = "r!h,U3I+3Z.-Gs_dTZ5L&1bsspo,ffb9Q"
Cells(k, j).Value = CStr(Asc(Mid(str, i, 1)))
If Len(str) > 1 Then
str = Right(str, Len(str) - 1)
Else
MsgBox ("Value of str is now " & str & " for k of " & k)
End If
i = i + 1
Next j
Next k
End Sub