Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,226 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,344 people online right now. Registration is fast and FREE... Join Now!




Problem loading arrays from file

 
Reply to this topicStart new topic

Problem loading arrays from file, loading + dropdown list lookup

sam_wong
13 Oct, 2008 - 09:38 AM
Post #1

New D.I.C Head
*

Joined: 13 Oct, 2008
Posts: 5

i am having trouble loading arrays from file.
there is an error in 'NewItem' which in bold and wat should i write for the button click event to load everything(load arrays item into a drop down list + showing the selected item at the label)
CODE

Public Class frmPurchase
    Dim bValid As Boolean = True
    Dim StatesArray(0) As String
    Dim CodesArray(0) As String
    Dim StateCodes As New Collection

Sub Page_Load()
        Dim FieldArray(3) As String
        Dim FileReader As StreamReader
        Dim LineIn As String
        Dim CodesArray(0) As String
        Dim sFileName As String

        sFileName = Application.StartupPath & "\PCTVehicles.txt"
        FileReader = File.OpenText(sFileName)
        LineIn = FileReader.ReadLine()

        While LineIn <> ""
            FieldArray = Split(LineIn, ",")
            StatesArray(UBound(StatesArray)) = FieldArray(0)
            CodesArray(UBound(CodesArray)) = FieldArray(1)
            LineIn = FileReader.ReadLine()
            If LineIn <> "" Then
                ReDim Preserve StatesArray(StatesArray.Length)
                ReDim Preserve CodesArray(CodesArray.Length)
            End If
        End While
        FileReader.Close()


    End Sub
    Sub DropDownList()
        Dim i As Integer
        For i = 0 To UBound(StatesArray)
            cmbVehicleManufac.Items.Add(New [b]ListItem[/b](StatesArray(i), CodesArray(i)))
        Next
    End Sub

    Sub Get_The_Code(ByVal Src As Object, ByVal Args As EventArgs)
        lblShowManufac.Text = cmbVehicleManufac.SelectedItem.Value

    End Sub

End Class

*thank you for your help..i'm just a beginner in programming..*

This post has been edited by sam_wong: 13 Oct, 2008 - 09:40 AM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Problem Loading Arrays From File
13 Oct, 2008 - 09:41 AM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
What's the error you're getting.Showing where the error is occurring is important, but not as important as knowing what error you're receiving
User is offlineProfile CardPM
+Quote Post

sam_wong
RE: Problem Loading Arrays From File
13 Oct, 2008 - 09:17 PM
Post #3

New D.I.C Head
*

Joined: 13 Oct, 2008
Posts: 5

QUOTE(PsychoCoder @ 13 Oct, 2008 - 10:41 AM) *

What's the error you're getting.Showing where the error is occurring is important, but not as important as knowing what error you're receiving



it shows type 'ListItem' is not defined in this sub
CODE
Sub DropDownList()
        Dim i As Integer

        For i = 0 To UBound(StatesArray)
            cmbVehicleManufac.Items.Add(New [color=#FF0000]ListItem[/color](StatesArray(i), CodesArray(i)))
        Next
    End Sub



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 03:04AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month