Results 1 to 4 of 4

Thread: [RESOLVED] Can someone help me plese

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Location
    Aylesbury, England
    Posts
    9

    Resolved [RESOLVED] Can someone help me plese

    I am trying to write a program that for an RPG. the program works like a shop where the user selects the item froma combo box and it is added to a list box, this part works but the function to total the price doesnt work. when i try it overwrites the data already in the box.

    Here is the code that i am using

    Code:
    Private Sub Command1_Click()
    List1.AddItem Combo1.Text
    Label1.Caption = Combo1.ItemData(Combo1.ListIndex)
    End Sub
    
    Private Sub Form_Load()
    Combo1.AddItem "Laser pistol"
    Combo1.ItemData(Combo1.NewIndex) = 1000
    Combo1.AddItem "Laser SMG"
    Combo1.ItemData(Combo1.NewIndex) = 1500
    End Sub
    can anyone help?

    thanks in advance

  2. #2
    Hyperactive Member jp26198926's Avatar
    Join Date
    Sep 2008
    Location
    General Santos City, Philippines
    Posts
    310

    Re: Can someone help me plese

    try this:
    Code:
    Dim a As Double
    
    Private Sub Command1_Click()
    List1.AddItem Combo1.Text
    a = a + Val(Combo1.ItemData(Combo1.ListIndex))
    Label1.Caption = a
    End Sub
    
    Private Sub Form_Load()
    Combo1.AddItem "Laser pistol"
    Combo1.ItemData(Combo1.NewIndex) = 1000
    Combo1.AddItem "Laser SMG"
    Combo1.ItemData(Combo1.NewIndex) = 1500
    End Sub
    "More Heads are Better than One"

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Location
    Aylesbury, England
    Posts
    9

    Re: Can someone help me plese

    thanks, that worked

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Can someone help me plese

    Quote Originally Posted by Stormcrow
    thanks, that worked
    Welcome to the forums.

    As a newer member I ask that if you consider your question to be resolved please help us out by pulling down the Thread Tools menu and clicking the Mark Thread Resolved menu item. That will let everyone know that you have your answer.

    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width