LBound and UBound question

  • Thread starter Thread starter Starbuck
  • Start date Start date
S

Starbuck

Hi All

In one of my converted (VB6 to VB.Net) apps I have managed to remove all instances of -
Imports Microsoft.VisualBasic - except for one form which raises errors in regard to LBound and UBound, the code in queston is below.



Private Sub ReadUsedIDs()

cboIndex.Items.Clear()

Dim Indexies As Object

Dim Size As Long

Try

Indexies = pICalendarItemServ.GetAllUsedIds(pItemType)

Size = UBound(Indexies) - LBound(Indexies) + 1

Dim index As Integer

For index = LBound(Indexies) To UBound(Indexies)

cboIndex.Items.Add(CType(Indexies(index), String))

Next

If (UBound(Indexies) - LBound(Indexies) > -1) Then

cboIndex.Text = Indexies(LBound(Indexies))

cmdRead.Enabled = True

cboIndex.Enabled = True

Else

cmdRead.Enabled = False

cboIndex.Enabled = False

End If

Indexies = Nothing

Catch ex As Exception

End Try

End Sub



Is there another way of doing this.

Thanks in advance
 
Starbuck said:
In one of my converted (VB6 to VB.Net) apps I have managed to remove all
*Why?!*

except for one form which raises errors in regard to LBound
and UBound, the code in queston is below.

If you want to go the .NET way (the question "Why?!" remains) you can use
'Indices.Length', 'Indices.GetLength', 'Indices.GetLowerBound',
'Indices.GetUpperBound'. An array's lower bound is always 0 for .NET
arrays.
 
In one of my converted (VB6 to VB.Net) apps I have managed to remove all
instances of -
Imports Microsoft.VisualBasic - except for one form which raises errors in
regard to LBound and >UBound, the code in queston is below.

Why?

However what I never use is LBound and UBound

0 and length - 1 or count -1 does everything for me.

Just my thought,

Cor
 
Back
Top