Noob help with VB2005

Discussion in 'General Programming Chat' started by mandude, Oct 15, 2008.

  1. mandude

    mandude Senior Member

    Joined:
    Feb 18, 2008
    Messages:
    870
    Likes Received:
    329
    Location:
    Tampa FL
    Hey all. I figured Id ask here because there are so many people here, and I dont have time to sign up to 100s of coding forums to ask this. If anyone can help please do!

    I am a noob with VB and am trying to get a combo box to work. I am just trying to make it so when the user selects one of the items in the drop down box, it hides that form and loads another.

    i see everwhere to use 'combobox.AddItems("") but additems doesnt work in vb2005. I tried items.add("") and I dont get errors, but nothing loads in the drop down. I also just used the properties and added the items, which it shows, but then I cant get the click proceedures to work. please help this project is due tomorrow!
     
  2. kalekom

    kalekom Junior Member

    Joined:
    Jul 25, 2008
    Messages:
    172
    Likes Received:
    357
    Occupation:
    CEO - SEO
    Location:
    here
    Check your combobox name!!!

    ComboBox1.Items.Add("asdf")

    I used VS 2008
     
  3. mandude

    mandude Senior Member

    Joined:
    Feb 18, 2008
    Messages:
    870
    Likes Received:
    329
    Location:
    Tampa FL
    I have the right name. it would give me errors if i didnt have the right one. I have
    cmbapp.Items.Add("main")
    but it doesnt add anything
     
  4. kalekom

    kalekom Junior Member

    Joined:
    Jul 25, 2008
    Messages:
    172
    Likes Received:
    357
    Occupation:
    CEO - SEO
    Location:
    here
    Where did you added your cmbapp.Items.Add("main") ?

    Between:
    Private Sub Form1_Load



    End Sub
     
    • Thanks Thanks x 1
  5. mandude

    mandude Senior Member

    Joined:
    Feb 18, 2008
    Messages:
    870
    Likes Received:
    329
    Location:
    Tampa FL
    yea I even thought maybe form1 needs to be the name of the form so i changed it to

    Private Sub cmbapp_load()
    cmbapp.Items.Add("main")
    cmbapp.Items.Add("test1")
    End Sub

    but still nothi ng.

    Like I said, I can change the items if I just go to properties and click 'add items' but then the problem still arises when I want those items to load new forms.
     
  6. kalekom

    kalekom Junior Member

    Joined:
    Jul 25, 2008
    Messages:
    172
    Likes Received:
    357
    Occupation:
    CEO - SEO
    Location:
    here
    No idea...

    I usually use c# or php.

    My combobox works just fine, here what i did:
    Drag combo to form
    double click form(not combo) - this creates correct Form_Load function
    insert your code
    Run

    Done
     
  7. mandude

    mandude Senior Member

    Joined:
    Feb 18, 2008
    Messages:
    870
    Likes Received:
    329
    Location:
    Tampa FL
    ok I got the box to load the text at start, I am an idiot and was trying to do a load method for the BOX, not the form. not only that, there is a bunch of code (ByVal, handles ect) that werent included when I typed it myself. and that solved the coding part too. want I wanted was for it to load a different form when one of the drop downs was selected. my code is this

    Dim cmbvar As String
    cmbvar = cmbapp.Text

    If cmbvar = "Main" Then

    Me.Hide()
    Main.Show()

    it works. but a quick question, when I go back and forth, (I think it has to do with hiding it) the main window loses focus, I believe this is the problem. example

    I open the app, the main form opens. I click the payroll button, and the payroll form shows and main hides. then i click the drop down menu and select main. the payroll hides, and i have the code to show the main form, but it stays minimized. Can you help? thanks
     
  8. razohad

    razohad Power Member

    Joined:
    Jan 11, 2008
    Messages:
    701
    Likes Received:
    1,005
    Occupation:
    Software engginer
    Location:
    online most of the time
    just add after
    main.show()

    this code:

    main.WindowState = FormWindowState.Normal
    main.focus()


    let me know if that helps
     
  9. mandude

    mandude Senior Member

    Joined:
    Feb 18, 2008
    Messages:
    870
    Likes Received:
    329
    Location:
    Tampa FL
    didnt work. crap. i dunno whatt the problem is.
     
  10. kalekom

    kalekom Junior Member

    Joined:
    Jul 25, 2008
    Messages:
    172
    Likes Received:
    357
    Occupation:
    CEO - SEO
    Location:
    here
    I tried and it same happened to me also...

    Then I tried to run compiled program independently without VS and it works
     
  11. razohad

    razohad Power Member

    Joined:
    Jan 11, 2008
    Messages:
    701
    Likes Received:
    1,005
    Occupation:
    Software engginer
    Location:
    online most of the time
    ok wired,

    try this:

    instead of Main.hide()

    write

    Main.Opacity = 0
    Main.ShowInTaskbar = False

    and when you want to show it again
    instead of Main.show()

    write
    Main.Opacity = 1
    Main.ShowInTaskbar = Ture


    let me know

     
  12. mandude

    mandude Senior Member

    Joined:
    Feb 18, 2008
    Messages:
    870
    Likes Received:
    329
    Location:
    Tampa FL
    hmm. works one way but not both. Heres what is happening:

    in main form, if I have it as payroll.show() and then your code it works, and then in payroll I have (when they click main)
    Me.Opacity = 0
    Me.ShowInTaskbar = False
    Main.Opacity = 1
    Main.ShowInTaskbar = True
    that worked at first. but when I changed mains code to

    Me.Opacity = 0
    Me.ShowInTaskbar = False
    Payroll.Opacity = 1
    Payroll.ShowInTaskbar = True

    it just hid them both and i had to stop debugging from vb cuz I couldnt see the windows.
     
  13. mandude

    mandude Senior Member

    Joined:
    Feb 18, 2008
    Messages:
    870
    Likes Received:
    329
    Location:
    Tampa FL
    oh I ment to say I would use it the first way, but there is a problem because I have a promptbox with payroll, and with the opacity code, it doesnt hide main until after the promt (weird) unless there is a way to fix that. its on load.
     
  14. razohad

    razohad Power Member

    Joined:
    Jan 11, 2008
    Messages:
    701
    Likes Received:
    1,005
    Occupation:
    Software engginer
    Location:
    online most of the time
    oh I see

    then add
    Application.doevents()
    for each one
     
  15. mandude

    mandude Senior Member

    Joined:
    Feb 18, 2008
    Messages:
    870
    Likes Received:
    329
    Location:
    Tampa FL
    didnt do anything. It works once, then if I try to do it again nothing shows. ill click payroll, then go to main, works once, but if I try to go to payroll again everything hides.
     
  16. razohad

    razohad Power Member

    Joined:
    Jan 11, 2008
    Messages:
    701
    Likes Received:
    1,005
    Occupation:
    Software engginer
    Location:
    online most of the time
    if you want i an look at the ode for you and see whats causing it.
    hit m on msn
     
    • Thanks Thanks x 1
  17. mandude

    mandude Senior Member

    Joined:
    Feb 18, 2008
    Messages:
    870
    Likes Received:
    329
    Location:
    Tampa FL
    I think I just fixed it. I just changed one to opacity and one to .show. seemed to like that better on both. I will hit you up on msn if I need help later though, thanks!