473,505 Members | 15,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

why does this error out at last line

14 New Member
Expand|Select|Wrap|Line Numbers
  1. Public Function getValue(strInput As String, lngStart As Long, Optional lngEnd As Long = 0)
  2.     'Get starting location
  3.         Dim lngPosStart As Long
  4.         Dim strStart As String
  5.         strStart = vbCrLf & lngStart & "."
  6.         lngPosStart = InStr(1, strInput, strStart) + Len(strStart)
  7.     'Get end location (if any)
  8.         Dim lngPosEnd As Long
  9.         If lngEnd <> 0 Then
  10.             lngPosEnd = InStr(1, strInput, vbCrLf & lngEnd & ".")
  11.         Else
  12.             lngPosEnd = Len(strInput)
  13.         End If
  14.  
  15.     getValue = Mid(strInput, lngPosStart, lngPosEnd - lngPosStart)
  16.  
  17. End Function
  18.  
Mar 8 '11 #1
2 1334
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
When asking about errors ALWAYS post the err number and full error description!

To debug issues such as this, use the Debug.Print or Msgbox. An example use could be:
Expand|Select|Wrap|Line Numbers
  1. Msgbox "Values:" & vbnewline & _
  2.        "  " & lngPosStart:   " & lngPosStart & vbnewline
  3.        "  " & lngPosEnd:     " & lngPosEnd
  4. getValue = Mid(strInput, lngPosStart, lngPosEnd - lngPosStart)
Now the msgbox will tell you what the values are, and you can probably see why its causing an error.
Mar 8 '11 #2
JEFFREY MUSGRAY
14 New Member
Thanks, as always you educate me. The error was invalid argument
Mar 8 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2913
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
11
12415
by: Kenneth | last post by:
I have a flat file on the server which I append to from a HTML web form. I need to delete the last line of the flat file before I append though. How do i do that? I have the following code. ...
8
2328
by: nephish | last post by:
Hey there. i want to set a variable to represent the last line of a text file how do i do that? or even better, how do i create a list of the lines of a text file?
4
10214
by: Charles Erwin | last post by:
Is there any way, upon scanning in a file line by line to avoid missing the last line if there is not a newline character (aka you have to hit return on the last line of input in your file). I was...
16
796
by: DJP | last post by:
Hi, I need to read a file programmatically until end of file. My logic is as follows: while(!feof(Fp)) { fgets(readLine,10000,Fp);
2
3801
by: Eric Lilja | last post by:
Hello, I'm writing a simple program that upon start-up needs to open a text file and read a value on the last line. Then all other accesses to the file will be writes (at the end of it). I'm having...
35
11335
by: RyanS09 | last post by:
Hello- I am trying to write a snippet which will open a text file with an integer on each line. I would like to read the last integer in the file. I am currently using: file = fopen("f.txt",...
3
2823
by: seven.reeds | last post by:
Hi, I am running php v 5.0.0 on a redhat box. I have a php script in a file called p_script_1. I have another small script in file p_script_2. p_script_1 calles p_script_2 through a system()...
7
25856
by: DemonWasp | last post by:
I've been having some trouble getting the Scanner class to operate the way I'd like. I'm doing some fairly basic file IO and I can't seem to get the class to load the last line/token any way I try....
6
5766
by: magix | last post by:
Hi, when I read entries in file i.e text file, how can I determine the first line and the last line ? I know the first line of entry can be filtered using counter, but how about the last line...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7018
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.