lesser-equity

Magazine
Go Back   Computer Juice > Computer Software > General Software Chat


Register


Reply
 
Thread Tools
  #1  
Old 13th Jan 2009, 04:15
Member Group
 
i am making a program in visual basic and i requires me to open a new from from the appliction.. heres what im doing-


i made a lstbox and inside a few options...
i want each of those options (when clicked) to open a new form i have premade but not already open... i HAVE made the forms
i HAVENT got the coding so i dont know how to code it, help please?
  #2  
Old 15th Jan 2009, 06:34
Donor Group
 
You need four lines at the right places.

Dim MyForm As FormName (somewhere at the start of the function you're calling it from)

MyForm = New FormName() (makes you a new copy of the form in memory)


MyForm.Show() (displays it in the window)


MyForm = Nothing (wipes it from memory when you're finished with it)
__________________

My System: Tim

Processor(s):
Athlon 64 3500+
Motherboard:
Asus A8N-VM CSM
RAM Memory:
Corsair PC3200 CL2 DDR-400 2GB
Graphics Card(s):
nVidia Geforce 6600 512MB
Sound Card:
Cherry RS 6000 M keyboard
Hard Drive(s):
Barracuda.7+ 2x200GB 58MB/s sustain
Optical Drive(s):
Samsung DVD-ROM TS-H352
Case / PSU:
Thermaltake Soprano
Cooling:
Stock
Network / Internet:
Telewest 2x20Mb/sec
Monitor(s):
SXGA flat panel
Operating System(s):
Slackware (2.6.27.7) (Fluxbox)
  #3  
Old 15th Jan 2009, 06:37
Member Group
 
thanks i hope it works
  #4  
Old 15th Jan 2009, 06:39
Donor Group
 
Before the .Show() you might want to set the x:y position to display it at, and maybe the size, and perhaps match the color. Any runtime attribute you want to change, that's where to do it. Then it shows up the way you expect it to.
  #5  
Old 15th Jan 2009, 06:40
Member Group
 
can you please post au much as you possibly can is they way i should type it please? i havent done this before!

thanx
  #6  
Old 15th Jan 2009, 06:51
Donor Group
 
There are far better tutorials than I could type from memory, I don't have Visual Basic to check against or copy bits from.

http://www.vb-helper.com/tutorial_sizing_forms.html shows the sort of code. The window you have at runtime has little to do with how it was when you were in design mode, the user has complete control of the size. If you're putting a new form into the window you could leave it where you designed it - that's easiest - or you could expand it to fit the space the user's given.
  #7  
Old 17th Jan 2009, 09:31
Member Group
 
hmm... what i would do is create a timer that started when the form opens. then, with timer1_tick, it would check if the listbox was one of several choices.
  #8  
Old 22nd Jan 2009, 19:45
Member Group
 
Double click on the listbox until the coding shows.
You should see:

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

End Sub

Type this in the area above:

If ListBox1.SelectedItem = "TheListBoxOptionText!" Then
YourFormName!.Show()
End If

Then when your done it should look like!

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
If ListBox1.SelectedItem = "Show Form 1" Then
Form2.Show()
End If
End Sub

Tip: Visual Basic Is NOT about remembering its ALL about understanding!




  #9  
Old 22nd Jan 2009, 20:12
Member Group
 
thanks im trying it now
  #10  
Old 22nd Jan 2009, 21:37
Member Group
 
thanks it works great
Reply

Register
Thread Tools




Arabic Bulgarian Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Finnish French German Greek Hebrew Hungarian Italian Japanese Korean Latvian Lithuanian Norwegian Polish Portuguese Romanian Russian Serbian Slovak Spanish Swedish Thai Turkish Ukrainian

Copyright ©2006 - 2009 Computer Juice.

Powered by vBulletin® Copyright ©2000 - 2009 Jelsoft Enterprises Ltd. SEO by vBSEO ©2009, Crawlability, Inc.