Noob help with VB2005

mandude

Senior Member
Jr. VIP
Joined
Feb 18, 2008
Messages
1,094
Reaction score
438
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!
 
Check your combobox name!!!

ComboBox1.Items.Add("asdf")

I used VS 2008
 
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
 
Where did you added your cmbapp.Items.Add("main") ?

Between:
Private Sub Form1_Load



End Sub
 
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.
 
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
 
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
 
just add after
main.show()

this code:

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


let me know if that helps
 
didnt work. crap. i dunno whatt the problem is.
 
I tried and it same happened to me also...

Then I tried to run compiled program independently without VS and it works
 
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

 
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.
 
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.
 
oh I see

then add
Application.doevents()
for each one
 
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.
 
if you want i an look at the ode for you and see whats causing it.
hit m on msn
 
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!
 
Back
Top