Hi Jeff,
You could use a list of objects to do this. On a design level, if the two
sets of values are distinct (i.e. your integers refer to one thing, your
strings to another) then I would separate them out into two lists. I
wouldn't be too comfortable lugging lists of Object around an application.
It's got unhandled exception written all over it ;). Although this was the
way with .NET 1.1, generics make it pointless. I suppose if you are
disciplined you can get away with it. Alternatively you could store them
all as string, parsing out the values into integers if needed. In the case
of object:
Dim myList As New List(Of Object)
myList.Add ( 1 )
myList.Add ( "One" )
For Each theObject As Object In myList
If TypeOf (theObject) Is Integer Then
' It's an integer
Dim theInteger = DirectCast(theObject, Integer)
ElseIf TypeOf (theObject) Is String Then
' It's a string
Dim theString As String = DirectCast(theObject, String)
Else
Throw New InvalidOperationException ( "Object type not supported" )
End If
Next
and for strings:
Dim myList As New List(Of String)
myList.Add ( 1.ToString )
myList.Add ( "one" )
For Each theString As String In myList
Dim theInteger As Integer
If Integer.TryParse ( theString, theInteger ) Then
' It's an integer string
Else
' It's a string
End
Robin
"Jeff" <no**@nothingX.comwrote in message
news:46***********************@free.teranews.com.. .
>
...still new to vb.net 2005
I understand the concept of arrays, and have used them in other languages,
but was hoping that someone could get me started with something.
I have a fairly long list of values that start in textboxes and listboxes
that are both integers and strings. I need to store them in an array to
pass to subs and stored procedures used in a database. Can I mix the
integers and strings (both of varying lengths) in the same array? If so,
could someone provide a simple example that I could build upon or point me
in the right direction?
Thanks
Jeff
--
Posted via a free Usenet account from http://www.teranews.com