array and list box connect?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • annie8508
    New Member
    • Apr 2012
    • 10

    array and list box connect?

    Hello..I'm almost done with this however. The selectedindex is not recognized and ("c0") is apparently should not be infinity?

    Please help I been working on this for a while


    Public Class Form1

    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load

    Dim strcountries() As String = {"United States", "France"} For intsubsript As Integer = 0 To 1 LstCountries.It ems.Add(strcoun tries(intsubsri pt)) Next intsubsript

    End Sub

    Private Sub LstCountries_Se lectedIndexChan ged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles LstCountries.Se lectedIndexChan ged

    Dim strcity() As String = {"Washington ", "Paris"}

    Dim strIndex As String = LstCountries.Se lectedIndex txtcity.Text = strcity(strInde x).ToString("co ")

    End Sub End Class
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    Is this VB6 ?
    If not , please place your call in the right forum.

    Comment

    • annie8508
      New Member
      • Apr 2012
      • 10

      #3
      Originally posted by Guido Geurs
      Is this VB6 ?
      If not , please place your call in the right forum.
      It's actually Visual Basic 2010 but I don't think there's much difference is there?

      Comment

      • Guido Geurs
        Recognized Expert Contributor
        • Oct 2009
        • 767

        #4
        The syntax of the code is quit different.
        In the "Visual Basic.Net" forum are a lot of experts to help you with this code.

        Comment

        • annie8508
          New Member
          • Apr 2012
          • 10

          #5
          thanks for the direction...I reposted in the .NET forum hopefully somebody can help..losing sleep is not my thing.

          Comment

          • rekedtechie
            New Member
            • Feb 2012
            • 51

            #6
            Code:
            'maybe try this..
            
            'General Declaration
            Dim StrCountry(),StrCity() As String
            
            'FormLoad
            Redim StrCountry(1)
            Redim StrCity(1)
            StrCountry() = {"U.S.","France"}
            StrCity() = {"Washington","Paris"}
            For i = 0 To UBound(StrCountry())
            List1.Add StrCountry(i)
            Next i
            
            'Listbox Click
            Text1.Text = StrCity(List1.SelectedIndex) & "co."
            Last edited by rekedtechie; Apr 9 '12, 03:29 PM. Reason: adding code tags

            Comment

            Working...