Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

VB array problem

I need to create an array to display a list price in a text box when I select an item number from a drop down combo box. See Example below:

Item Numbers List Price

1987 0
3243 25
3454 429
4324 32
4423 750
5423 75
6534 2.25
7364 125
7453 37.50
8745 1.25



The corresponding list price has to reflect the Item number selected from the combo box. Also, the result should be obtained using an array. Can anyone help?

Comments

  • infidelinfidel Member Posts: 2,900
    : I need to create an array to display a list price in a text box when I select an item number from a drop down combo box. See Example below:
    :
    : Item Numbers List Price
    :
    : 1987 0
    : 3243 25
    : 3454 429
    : 4324 32
    : 4423 750
    : 5423 75
    : 6534 2.25
    : 7364 125
    : 7453 37.50
    : 8745 1.25
    :
    :
    :
    : The corresponding list price has to reflect the Item number selected from the combo box. Also, the result should be obtained using an array. Can anyone help?

    Why do you need an array when you can use the ItemData property of the ComboBox to store the price along with the list items?

    [code]
    Private Sub Combo1_Click()

    Me.Text1.Text = Me.Combo1.ItemData(Me.Combo1.ListIndex)

    End Sub

    Private Sub Form_Load()

    With Me.Combo1
    .AddItem "foo"
    .ItemData(.NewIndex) = 10
    .AddItem "bar"
    .ItemData(.NewIndex) = 20
    .AddItem "gee"
    .ItemData(.NewIndex) = 30
    .AddItem "haw"
    .ItemData(.NewIndex) = 40
    End With

    End Sub
    [/code]

    If for some reason you really do need to use an array, you could just replace all of the ItemData references to your array name.
  • juice2k2juice2k2 Member Posts: 15
    I have to use an array because it is required by the assigment I am working on. Thanks












    : : I need to create an array to display a list price in a text box when I select an item number from a drop down combo box. See Example below:
    : :
    : : Item Numbers List Price
    : :
    : : 1987 0
    : : 3243 25
    : : 3454 429
    : : 4324 32
    : : 4423 750
    : : 5423 75
    : : 6534 2.25
    : : 7364 125
    : : 7453 37.50
    : : 8745 1.25
    : :
    : :
    : :
    : : The corresponding list price has to reflect the Item number selected from the combo box. Also, the result should be obtained using an array. Can anyone help?
    :
    : Why do you need an array when you can use the ItemData property of the ComboBox to store the price along with the list items?
    :
    : [code]
    : Private Sub Combo1_Click()
    :
    : Me.Text1.Text = Me.Combo1.ItemData(Me.Combo1.ListIndex)
    :
    : End Sub
    :
    : Private Sub Form_Load()
    :
    : With Me.Combo1
    : .AddItem "foo"
    : .ItemData(.NewIndex) = 10
    : .AddItem "bar"
    : .ItemData(.NewIndex) = 20
    : .AddItem "gee"
    : .ItemData(.NewIndex) = 30
    : .AddItem "haw"
    : .ItemData(.NewIndex) = 40
    : End With
    :
    : End Sub
    : [/code]
    :
    : If for some reason you really do need to use an array, you could just replace all of the ItemData references to your array name.
    :

  • Andre YoungAndre Young USAMember Posts: 0

    ______ // http://forcoder.org // free ebooks and video tutorials about // Swift C C++ Scratch Visual Basic .NET PHP Python JavaScript PL/SQL R Assembly Ruby Visual Basic Go C# Java Objective-C MATLAB Delphi Perl FoxPro Ada SAS COBOL Julia Transact-SQL Scala Awk Alice Prolog Hack F# Dart Lisp Scheme Kotlin Lua Rust Fortran Clojure LabVIEW Logo Erlang Apex Bash ABAP ML VBScript Crystal D //

Sign In or Register to comment.