PC Review


Reply
Thread Tools Rate Thread

Array bounds

 
 
Bill
Guest
Posts: n/a
 
      29th Jul 2006
Dim MyArray() As String
MyArray = split(MyString, " ")

If an array currently has two valid string
elements, MyArray(0) and MyArray(1), how
can the UBound(MyArray) be equal to -1?

(Base is defaulted to 0)


 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      29th Jul 2006
It can't be. Let's see the actual code you're using.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Bill" <(E-Mail Removed)> wrote in message
news:aONyg.1651$(E-Mail Removed)...
> Dim MyArray() As String
> MyArray = split(MyString, " ")
>
> If an array currently has two valid string
> elements, MyArray(0) and MyArray(1), how
> can the UBound(MyArray) be equal to -1?
>
> (Base is defaulted to 0)
>
>



 
Reply With Quote
 
Bill
Guest
Posts: n/a
 
      29th Jul 2006
My isolated test code:

Dim Parts() As String
strChairman = "(reference data) Bill"
Parts = Split(chairman, ")")
If UBound(Parts) > 0 Then
strRef = Right(Parts(0), Len(Parts(0)) - 1)
strChairman = Parts(1)
Else
strRef = "None"
End If
Debug.Print UBound(Parts) & ", " & LBound(Parts)
Debug.Print strRef
Debug.Print strChairman
Exit Sub

Immediate Window:

-1, 0
None
(reference data) Bill

I was, of course, expecting UBound to be "1".

Bill


"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:(E-Mail Removed)...
> It can't be. Let's see the actual code you're using.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Bill" <(E-Mail Removed)> wrote in message
> news:aONyg.1651$(E-Mail Removed)...
>> Dim MyArray() As String
>> MyArray = split(MyString, " ")
>>
>> If an array currently has two valid string
>> elements, MyArray(0) and MyArray(1), how
>> can the UBound(MyArray) be equal to -1?
>>
>> (Base is defaulted to 0)
>>
>>

>
>



 
Reply With Quote
 
RoyVidar
Guest
Posts: n/a
 
      29th Jul 2006
"Bill" <(E-Mail Removed)> wrote in message
<YsOyg.1683$(E-Mail Removed)>:
> My isolated test code:
>
> Dim Parts() As String
> strChairman = "(reference data) Bill"
> Parts = Split(chairman, ")")
> If UBound(Parts) > 0 Then
> strRef = Right(Parts(0), Len(Parts(0)) - 1)
> strChairman = Parts(1)
> Else
> strRef = "None"
> End If
> Debug.Print UBound(Parts) & ", " & LBound(Parts)
> Debug.Print strRef
> Debug.Print strChairman
> Exit Sub
>
> Immediate Window:
>
> -1, 0
> None
> (reference data) Bill
>
> I was, of course, expecting UBound to be "1".
>
> Bill


You split a variable called "chairman", but the one you've assigned
a value to, is "strChairman" ;-)

(Option Explicit?)

--
Roy-Vidar


 
Reply With Quote
 
Bill
Guest
Posts: n/a
 
      29th Jul 2006
Jeez! I see it.
Bill


"Bill" <(E-Mail Removed)> wrote in message
news:YsOyg.1683$(E-Mail Removed)...
> My isolated test code:
>
> Dim Parts() As String
> strChairman = "(reference data) Bill"
> Parts = Split(chairman, ")")
> If UBound(Parts) > 0 Then
> strRef = Right(Parts(0), Len(Parts(0)) - 1)
> strChairman = Parts(1)
> Else
> strRef = "None"
> End If
> Debug.Print UBound(Parts) & ", " & LBound(Parts)
> Debug.Print strRef
> Debug.Print strChairman
> Exit Sub
>
> Immediate Window:
>
> -1, 0
> None
> (reference data) Bill
>
> I was, of course, expecting UBound to be "1".
>
> Bill
>
>
> "Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
> news:(E-Mail Removed)...
>> It can't be. Let's see the actual code you're using.
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "Bill" <(E-Mail Removed)> wrote in message
>> news:aONyg.1651$(E-Mail Removed)...
>>> Dim MyArray() As String
>>> MyArray = split(MyString, " ")
>>>
>>> If an array currently has two valid string
>>> elements, MyArray(0) and MyArray(1), how
>>> can the UBound(MyArray) be equal to -1?
>>>
>>> (Base is defaulted to 0)
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Bill
Guest
Posts: n/a
 
      29th Jul 2006
Wouldn't you know it! The only module I have in
all my mdb's that was missing its Option Explicit!
Thanks,
Bill


"RoyVidar" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Bill" <(E-Mail Removed)> wrote in message
> <YsOyg.1683$(E-Mail Removed)>:
>> My isolated test code:
>>
>> Dim Parts() As String
>> strChairman = "(reference data) Bill"
>> Parts = Split(chairman, ")")
>> If UBound(Parts) > 0 Then
>> strRef = Right(Parts(0), Len(Parts(0)) - 1)
>> strChairman = Parts(1)
>> Else
>> strRef = "None"
>> End If
>> Debug.Print UBound(Parts) & ", " & LBound(Parts)
>> Debug.Print strRef
>> Debug.Print strChairman
>> Exit Sub
>>
>> Immediate Window:
>>
>> -1, 0
>> None
>> (reference data) Bill
>>
>> I was, of course, expecting UBound to be "1".
>>
>> Bill

>
> You split a variable called "chairman", but the one you've assigned
> a value to, is "strChairman" ;-)
>
> (Option Explicit?)
>
> --
> Roy-Vidar
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
determining array with no bounds set? =?Utf-8?B?bWFyaw==?= Microsoft Excel Programming 1 22nd Jun 2007 09:53 PM
Array Question, Out of Bounds RallyDSM Microsoft VB .NET 5 27th Nov 2006 08:50 PM
Index was outside the bounds of the array =?Utf-8?B?Q2FtbWllIFdhdHNvbg==?= Microsoft ASP .NET 3 28th Nov 2005 05:53 PM
array index out of bounds =?Utf-8?B?dG9t?= Microsoft Outlook BCM 1 28th Jan 2005 10:26 PM
Index was outside the bounds of the array Antoine Microsoft VB .NET 10 15th Dec 2004 08:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:30 PM.