-
Hello...I'm a beginner VB student and I'm apart of a group project that we need to do the following.
Use the controls listed below to development a program to showcase a product. We need to have 2 screens. The first screen has to have the product info and options. Then we have to make the selections we made onthe first page show up on an invoice page. The controls we must use are the following:
Text Box (min of 2), Option box (min of 4), Combo box (min of 2), picture box(min of 1), scroll bars(min of 1), command buttons (min of 2).
What we need to know is how. After we have 2 combo box for the product selection & shipping method and a option buttons for quantity of the product, how can we get the total order onto another form in like a invoice form?
Also how can I put price values on each item in the list of a combo?
PLEASE!!!! Email if you have any info for me. Email if you need clarity.
thanx
Kelly
[email protected]
-
<?>
Are you selecting multiple items form page 1 or just 1 item with 1 qantity and then having that transferred over to page 2
example
rope
stick
pie
1
2
3
4
can you pick 2 ropes and 3 sticks and 1 pie
or is it only 1 rope or 2 sticks or 3 pies.
-
Multiple items
Were using combo boxes to select items, option button for quantity, and another combo for shipping method... so we can have different combination....
-
Start with this
Start with this and just keep working on it till you get it.
Code:
Private Sub cmdContinue_Click()
Dim var ' choose the data type you need
Select Case Combo1.ListIndex
Case 0 'first item is index of 0
var = "some amount"
Case 1
var = "different amount"
Case 2
var = "another amount"
End Select
Form2!TextTotal.Text = var
'To put something into a textbox on a diiferent form
' use the "Bang" operator "!". Do calculations here.
'Total = var + var2 + var 3
'Form2!TextTotal.Text = Total
Form2.Show
Unload Me
End Sub
Have fun
-
<?>
Here is a sample of what you are doing. It is not meant to be your finished product. It is meant to be a teaching tool and hopefully from it you can see what you need to address in programming your application.
Code:
'Bas Module Code
Option Explicit
Public Sub UnloadAll()
'unload all forms in project
Dim i As Integer
' Loop through the forms collection and unload
' each form.
For i = 1 To Forms.Count
Unload Forms(0)
Next i
End Sub
Public Sub DisableOpt()
'disable all Option Buttons on Form
'mycontrol = control and increment is increment for forms
'some situtations use more than one form.
'
Dim ctlMyControl As Control
Dim intIncrement As Integer
'
For intIncrement = 0 To Forms.Count - 1
For Each ctlMyControl In Forms(intIncrement).Controls
'
If TypeOf ctlMyControl Is OptionButton Then
'
ctlMyControl.Enabled = False
'
End If
'
Next ctlMyControl
'
Next intIncrement
'
End Sub
Public Sub EnableOpt()
'enable all Option Buttons on Form
'mycontrol = control and increment is increment for forms
'some situtations use more than one form.
'
Dim ctlMyControl As Control
Dim intIncrement As Integer
'
For intIncrement = 0 To Forms.Count - 1
For Each ctlMyControl In Forms(intIncrement).Controls
'
If TypeOf ctlMyControl Is OptionButton Then
'
ctlMyControl.Enabled = True
'
End If
'
Next ctlMyControl
'
Next intIncrement
'
End Sub
'Form One (frmOrder Code)
Option Explicit
'required to pass between subs on frmOrder
Public myPic As Integer
Public myItem As Integer
Private Sub cmdClear_Click()
'clear the textbox
txtOrder.Text = ""
End Sub
Private Sub cmdOrder_Click()
'hide one form and show the other
frmOrder.Hide
frmInvoice.Show
End Sub
Private Sub cmdQuit_Click()
'unload all forms
Call UnloadAll
End Sub
Private Sub Combo1_Click()
'keep all within the path of the application
Dim AppPath As String
If Right(App.Path, 1) <> "\" Then
AppPath = App.Path & "\"
Else
AppPath = App.Path
End If
'conditions for value of myPic used in Select
If Combo1.ListIndex = 1 Then myPic = 1
If Combo1.ListIndex = 2 Then myPic = 2
If Combo1.ListIndex = 3 Then myPic = 3
'
'if combo1.listindex = 0 then do nothing
'as we don't want the text from index 0 showing
'up in our order as it is only instructions
If Combo1.ListIndex <> 0 Then
'else do your stuff
Select Case myPic
Case 1
'show a picture of the product to the user
Set Picture1 = LoadPicture(AppPath & "doggie.gif")
'send the item description to the order box and the invoice
txtOrder.Text = txtOrder.Text & Combo1.Text & vbCrLf
frmInvoice.txtItem1.Text = frmOrder.Combo1.Text
'value myItem for use in Quantiy ordered of what
myItem = 1
'you've ordered it once that is it for the item in question
Combo1.RemoveItem (1)
'lock the combo so you cannot order again till you select a quantity
Combo1.Locked = True
'enable the option buttons so you can select a quantity
Call EnableOpt
'all cases are similar documentation:
Case 2
Set Picture1 = LoadPicture(AppPath & "rope.jpg")
txtOrder.Text = txtOrder.Text & Combo1.Text & vbCrLf
frmInvoice.txtItem2.Text = frmOrder.Combo1.Text
myItem = 2
Combo1.RemoveItem (2)
Combo1.Locked = True
Call EnableOpt
Case 3
Set Picture1 = LoadPicture(AppPath & "duckie.gif")
txtOrder.Text = txtOrder.Text & Combo1.Text & vbCrLf
frmInvoice.txtItem3.Text = frmOrder.Combo1.Text
myItem = 3
Combo1.RemoveItem (3)
Combo1.Locked = True
Call EnableOpt
End Select
End If
End Sub
Private Sub Combo1_LostFocus()
'once you lose focus reset the instructions on the combo1
Combo1.ListIndex = 0
End Sub
Private Sub Combo2_Click()
'if index not 0 then do your stuff
If Combo2.ListIndex <> 0 Then
'send the shipper to the invoice form
txtOrder.Text = txtOrder.Text & Combo2.Text & vbCrLf
frmInvoice.txtShip.Text = frmOrder.Combo2.Text
'get rid of shipper selection all items to one destination
'will go through one shipper (for this exercise)
'advise customer that shipper is selected
Combo2.Visible = False
lblShip.Caption = "Your Shipment Carrier Has Been Selected."
lblShip.Visible = True
End If
End Sub
Private Sub Form_Load()
'load the comboboxes with information
Combo1.AddItem "Click Once To Add To Order"
Combo1.AddItem "Item 1: Men's Soap On A Rope"
Combo1.AddItem "Item 2: Womens Soap In A Sponge"
Combo1.AddItem "Item 3: Child's Rubber Duckie"
Combo2.AddItem "Click on shipper to Ship Via:"
Combo2.AddItem "Purolator"
Combo2.AddItem "Federel Express"
Combo2.AddItem "Quickie Express"
'set the instruction to the top of combobox
Combo1.ListIndex = 0
Combo2.ListIndex = 0
'disable the quantity options till needed
Call DisableOpt
End Sub
Private Sub Option2_Click()
'here, based on the value of my item we decide which
'quantity to send to which box of the invoice form
Select Case myItem
Case 1
frmInvoice.txtQty1.Text = 1
Case 2
frmInvoice.txtQty2.Text = 1
Case 3
frmInvoice.txtQty3.Text = 1
End Select
'here we send the quantity to the order textbox
txtOrder.Text = txtOrder.Text & "Qty. Ordered = 1" & vbCrLf
'we set the value back to the instructions so it will
'be available on return for another quantity of different item
Option1.Value = True
'disable the buttons to avoid user misuse
Call DisableOpt
'unlock the combo1 so the user can select another item
Combo1.Locked = False
End Sub
'
'Same Documention as other option buttons
Private Sub Option3_Click()
Select Case myItem
Case 1
frmInvoice.txtQty1.Text = 2
Case 2
frmInvoice.txtQty2.Text = 2
Case 3
frmInvoice.txtQty3.Text = 2
End Select
txtOrder.Text = txtOrder.Text & "Qty. Ordered = 2" & vbCrLf
Option1.Value = True
Call DisableOpt
Combo1.Locked = False
End Sub
Private Sub Option4_Click()
Select Case myItem
Case 1
frmInvoice.txtQty1.Text = 3
Case 2
frmInvoice.txtQty2.Text = 3
Case 3
frmInvoice.txtQty3.Text = 3
End Select
txtOrder.Text = txtOrder.Text & "Qty. Ordered = 3" & vbCrLf
Option1.Value = True
Call DisableOpt
Combo1.Locked = False
End Sub
'Form 2 (frmInvoice)
Option Explicit
Private Sub cmdQuit_Click()
'unload all forms
Call UnloadAll
End Sub
Private Sub cmdReturn_Click()
'unload this form and show the order form
Unload frmInvoice
frmOrder.Show
'set the index to show the instructions
frmOrder.txtOrder.Text = ""
'set the combo2 back to visible
frmOrder.Combo2.Visible = True
'empty the textbox on frmOrder
frmOrder.Combo2.ListIndex = 0
'hide the ship label till needed
lblShip.Visible = False
'disbale the option buttons
Call DisableOpt
End Sub