So I have a code atm that has 2 combo boxes, one to select the make, then it will enable the model, I have 3 model choices, here's code:
Public Class Form2
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
End Sub
Private Sub cmb_make_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cmb_make.Items.Add("Toyota")
cmb_make.Items.Add("Nissan")
cmb_make.Items.Add("Hyundai")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e 开发者_如何学编程As System.EventArgs) Handles btn_finish.Click
If cmb_make.Text = "" Then
MsgBox("Please select your make")
End If
If cmb_model.Text = "" Then
MsgBox("Please select your model")
End If
If cmb_model.Text = ("Supra") Then
Form3.Show()
Me.Close()
End If
If cmb_model.Text = ("MR2") Then
Form4.Show()
Me.Close()
End If
If cmb_model.Text = ("Hilux") Then
Form5.Show()
Me.Close()
End If
If cmb_model.Text = ("R34") Then
Form6.Show()
Me.Close()
End If
If cmb_model.Text = ("R33") Then
Form7.Show()
Me.Close()
End If
If cmb_model.Text = ("R32") Then
Form8.Show()
Me.Close()
End If
If cmb_model.Text = ("Genesis Coupe") Then
Form9.Show()
Me.Close()
End If
If cmb_model.Text = ("RD1 Coupe") Then
Form10.Show()
Me.Close()
End If
If cmb_model.Text = ("Excel") Then
Form11.Show()
Me.Close()
End If
End Sub
Private Sub EditToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EditToolStripMenuItem.Click
End Sub
Private Sub cmb_make_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_make.SelectedIndexChanged
Dim Strchoice As String
Strchoice = cmb_make.SelectedItem
If Strchoice = "Toyota" Then
End If
cmb_model.Items.Clear()
cmb_model.Items.Add("Supra")
cmb_model.Items.Add("MR2")
cmb_model.Items.Add("Hilux")
If Strchoice = "Nissan" Then
cmb_model.Items.Clear()
cmb_model.Items.Add("R34")
cmb_model.Items.Add("R32")
cmb_model.Items.Add("R33")
ElseIf Strchoice = "Hyundai" Then
cmb_model.Items.Clear()
cmb_model.Items.Add("RD1 Coupe")
cmb_model.Items.Add("Genesis Coupe")
cmb_model.Items.Add("Excel")
Once I have selected my model of the car, it takes me to that specific form with a picture of that model, I then want to display individual parts, with individual prices that will add up in a text box above, can someone help me and tell me how? Please this is due tomorrow I'm freaking out!!
You can put the parts into picture boxes on the model's form and have either check boxes or radio buttons (depending on what functionality you are required to do) underneath that have the prices as labels and then use an if structure to assign a value to them that can be totaled in the text box.
Dim total as double
If chk_part1.checked = true then
total += partPrice
If chk_part2.checked = true then
total += partPrice
txtTotal.text = total
Not saying that this code is perfect but you could implement something along those lines to get the results you're looking for.
You can also do a For Each Statement. Such as:
Dim Form As New Form3.ControlCollection(Me)
For Each CheckBox As CheckBox In Form
If CheckBox.Checked = True Then
total += partPrice
End If
Next
So, In essense, it should cycle through all of the check boxes and, if they are checked, it adds the part price to the total.
精彩评论