Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a form depending on value in list box & option button 1

Status
Not open for further replies.
Mar 18, 2004
7
0
0
US
I am trying to write a sizing program in VB6.
I have a home form designed out and have a list box and 3 option buttons in a frame. I want the user to have to select an item in the list box and one of the option button. Then i want it to open up another form depending on the what they have selected.
Example in my list box i have 10 different items, Apartment, Club, hospital, Hotel, etc... my three options buttons are english, metric, imperial. If I select Hospital and english it will take me to my hostpitalenglish form.
I have made 30 different forms depending on the type(list box)& Size(option button.)
Am I going at this the wrong way?
Can someone please help me with the code are steer me in the right direction?
Please Help. I have took a couple of classes on VB a couple of years ago and have not used it since then.
 
I think you'd better tell us what the difference between those forms.
if the only difference is the caption, then you can just change it when you load it.

but I bet it's not that simple though. :)
 
I have differnt items listed on each form and will be using different calculation on each of them.
 
I don't know if I got you correctly.
maybe you can use frames in on form.
and display one frame base on the option.
and use different calculation.
 
This is quick and dirty way to display your forms.
Tried to employ CallByName function but could not find out how to do it, so used Select Case mstrForm instead.

This is example for your forms, but I would recommend some tab control.

Option Explicit

Private Type udtForm

ApartmentEnglish As String
ApartmentMetric As String
ApartmentImerial As String

ClubEnglish As String
ClubMetric As String
ClubImerial As String

HospitalEnglish As String
HospitalMetric As String
HospitalImerial As String

HotelEnglish As String
HotelMetric As String
HotelImerial As String

End Type

Private FormName As udtForm
Private mstrUnit As String
Private mstrForm As String


Private Sub cmdLoadForm_Click()

mstrForm = BuildFormName(Combo1.Text)

Select Case mstrForm
Case "frmHospitalEnglish": frmHospitalEnglish.Show
Case "frmHospitalMetric": frmHospitalMetric.Show
'and so on
End Select

End Sub

Private Sub Form_Load()
With Combo1
.AddItem "Apartment"
.AddItem "Club"
.AddItem "Hospital"
.AddItem "Hotel"
End With
End Sub

Private Function BuildFormName(ByVal pstrBuilding As String) As String

BuildFormName = "frm" & pstrBuilding & mstrUnit

End Function

Private Sub optEnglish_Click()
mstrUnit = "English"
End Sub

Private Sub optImperial_Click()
mstrUnit = "Imperial"
End Sub

Private Sub optMetric_Click()
mstrUnit = "Metric"
End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top