Link to home
Start Free TrialLog in
Avatar of lindapat
lindapat

asked on

vb.net arrays

I am new at VB.net and I have to creat arrays for the descriptions I wan to display on a screen. For example
"First Name"
"Address"
"Phone Number"
then I will pull the data to show up beside them.  Can anyone give me an example how to create an array for these descriptions.  I don't know how to create an array.

Thanks,
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

sample code


Public Class frmArrList
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        Test()
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ComponentModel.Container()
        Me.Text = "frmArrList"
    End Sub

#End Region

    Private Sub Test()
        Dim str As String = "John Doe, 1000 UptheStreet Drive, 145-423-9875"
        Dim strarr() As String

        strarr = str.Split(",")
        Dim sText As String
        Dim i As Integer
        Dim myAL As New ArrayList

        For i = LBound(strarr) To UBound(strarr)
            myAL.Add(strarr(i))
        Next

        sText = "First Name= " & strarr(0) & vbNewLine
        sText += "Address= " & strarr(1) & vbNewLine
        sText += "Phone Number= " & strarr(2) & vbNewLine
        MsgBox(sText)

    End Sub
End Class
ASKER CERTIFIED SOLUTION
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lindapat
lindapat

ASKER

Thank you sooooooo much. You have been a life saver.