msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

invalid procedure call with InStr()

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
nod



Joined: 09 Oct 2007
Posts: 10

PostPosted: Tue Oct 09, 2007 9:22 pm    Post subject: invalid procedure call with InStr() Reply with quote

I am getting an ' invalid procedure call or argument' error with
the following code which I am using to break down the line of a text
file. The line's contents are separated by tabs.

tabbing = Chr(9)
Dim nextEntry As String
tabPos = 0
nextTab = 0
Do Until EOF(1)
Line Input #1, nextLine
For i = 0 To 16
nextTab = InStr(tabPos, nextLine, tabbing)
nextEntry = Mid(nextLine, tabPos, nextTab - tabPos)
tabPos = nextTab


the error occurs at
nextTab = InStr(tabPos, nextLine, tabbing)

tabPos value is 0
tabbing value looks ok to me ( a box within inverted commas)
nextLine contains text and a lot of those symbols that are shown as
the tabbing value

I would be grateful if someone could explain how I should be doing
this.

Nod

Archived from group: microsoft>public>vb>syntax
Back to top
View user's profile Send private message
nod



Joined: 09 Oct 2007
Posts: 10

PostPosted: Tue Oct 09, 2007 9:39 pm    Post subject: Re: invalid procedure call with InStr() Reply with quote

Got it sorted by setting tabPos to 1.
I would still welcome any criticism of the code or approach.

Nod
Back to top
View user's profile Send private message
John Mishefske



Joined: 04 Oct 2007
Posts: 26

PostPosted: Tue Oct 09, 2007 4:43 am    Post subject: Re: invalid procedure call with InStr() Reply with quote

nod wrote:
> Got it sorted by setting tabPos to 1.
> I would still welcome any criticism of the code or approach.

For whatever reason a zero value for the StartPos argument to the
InStr() function is invalid. The first character is at position 1.

At a minimum I'd expect the application help to be very clear on this
issue but the user is left to deduct this from the samples in help.

--
'--------------------------
' John Mishefske
' UtterAccess Editor
' 2007 Microsoft Access MVP
'--------------------------

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group