dev_ven
asked on
VBScript error
Why is the following code giving an invalid procedure call or argument error
result = Mid(ThisString, 0, 1)
dev_ven said:
>>Why is the following code giving an invalid procedure call or argument error
Because you are telling the function to grab 1 character starting at position zero. That second argument
has to be a positive integer.
>>Why is the following code giving an invalid procedure call or argument error
Because you are telling the function to grab 1 character starting at position zero. That second argument
has to be a positive integer.
ASKER
I figured that, but when I change it to 1 I get the following error: Object Required
for the following code:
oaccess.Run PipeToTab("C:\Documents and Settings\lmb04\My Documents\Personal\Test.tx t", "C:\Documents and Settings\lmb04\My Documents\Personal\Convert edTest.txt ")
why do I get that error?
Below is my full code for my base problem.
Function PipeToTab(InputFile As String, OutputFile As String)
Dim ThisString As String
Dim NewString As String
Dim A As Integer
Dim result As String
Open InputFile For Input As #1
Open OutputFile For Output As #2
NewString = ""
Do While Not EOF(1)
Line Input #1, ThisString
For A = 1 To Len(ThisString)
If Mid(ThisString, A, 1) = "|" Then
NewString = NewString & Chr$(9)
Else
NewString = NewString & Mid(ThisString, A, 1)
End If
Next
Print #2, NewString
Loop
End Function
for the following code:
oaccess.Run PipeToTab("C:\Documents and Settings\lmb04\My Documents\Personal\Test.tx
why do I get that error?
Below is my full code for my base problem.
Function PipeToTab(InputFile As String, OutputFile As String)
Dim ThisString As String
Dim NewString As String
Dim A As Integer
Dim result As String
Open InputFile For Input As #1
Open OutputFile For Output As #2
NewString = ""
Do While Not EOF(1)
Line Input #1, ThisString
For A = 1 To Len(ThisString)
If Mid(ThisString, A, 1) = "|" Then
NewString = NewString & Chr$(9)
Else
NewString = NewString & Mid(ThisString, A, 1)
End If
Next
Print #2, NewString
Loop
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
result = Mid(ThisString, 1, 1)