|
-
Dec 17th, 2008, 04:13 PM
#1
Thread Starter
New Member
substring confusion
I'm trying to select all events which happen in a particular month using the following code (VB2008Express):
Public Fd(100,10) as String
for i=1 to 75
dim str as String=Fd(i,8).substring(1,2) (Fd(i,8) is a string date: 12/12/08)
using debug.print, this returns "2/" - not good. When I run this, I get a "ArgumentOutOf RangeException unhandled - Start index cannot be larger than length of string Parameter:start index"
When I run .Substring(0,2) I get "12", which is good, but (0,2) is not per the Help instructions for Substring. This also gives the "ArgumentOutOfRangeException - Index and length must refer to a location within the string Parameter:length"
I don't understand either exception. The start index does not seem to be larger than the string, and even if the index doesn't refer to a location within the string I get the correct return. I don't know what I need to fix and I certainly don't know what to use as a Catch phrase to correct whatever is wrong. Please someone set me straight , but don't make me look too inept.
joewillie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|