Hi there this is my first time here. I am working on a problem for school. I am working hard on solving a problem and hope someone can help me.
I am making an order form. I have the form all done. It asks for the name, address etc....
Next I made three listboxes: one with products by name, one by Product ID number, and one by product price. When the user clicks the save button I have the customer info go to one file and the order info to another. But I know I am doing something wrong.
On my form I also have a total for the order. My problem is that I can write the info to the files but I don't know how to add the total from the price listbox. Especiall since everytime I hit the save command button the listboxes are clearing. here is the code I have so far.
I don't want my homework done for me just a push or example in the right direction would be great.
Option Explicit
Private Sub cmdSaveFile_Click()
Dim strProductId As String
Dim strProductName As String
Dim curUnitPrice As Currency
Dim intQuantity As Integer
Dim strFname As String
Dim strLname As String
Dim strPaymentCode As String
Dim strCreditCode As String
Dim strCreditCardNumber As String
Dim strAddress As String
Dim strCity As String
Dim strState As String
Dim strZip As String
Dim Number As Integer
If lstProductId.ListIndex = -1 Then
MsgBox "Please Pick an item to order"
Exit Sub
End If
If vscQuantity.Value = 0 Then
MsgBox "Please pick a quantity"
Exit Sub
End If
Open "A:/P_SCSTMR.DAT" For Append As #20
strFname = txtFname.Text
strLname = txtLname.Text
If optPaymentCode(0) = True Then
strPaymentCode = 0
Else
strPaymentCode = 1
End If
If optCode(0) = True Then
strCreditCode = "V"
End If
If optCode(1) = True Then
strCreditCode = "M"
End If
If optCode(2) = True Then
strCreditCode = "N"
End If
If lblCreditNumber.Caption = "" Then
strCreditCardNumber = "X"
Else
strCreditCardNumber = lblCreditNumber.Caption
End If
strAddress = txtAddress.Text
strCity = txtCity.Text
strState = txtState.Text
strZip = txtZip.Text
Write #20, strFname, strLname, strPaymentCode, strCreditCode, strCreditCardNumber, strAddress, strCity, strState, strZip, Number
Close #20
Open "A:/P_SORDRS.DAT" For Append As #10
strProductId = lstProductId.List(lstProductId.ListIndex)
strProductName = lstProductName.List(lstProductId.ListIndex)
curUnitPrice = CCur(lstPrice.List(lstProductId.ListIndex))
intQuantity = vscQuantity.Value
Write #10, strProductId, strProductName, curUnitPrice, intQuantity
Close #10
lstProductId.ListIndex = -1
vscQuantity.Value = 0
End Sub
Private Sub Form_Load()
Dim strProductId As String
Dim strProductName As String
Dim curUnitPrice As Currency
Dim intRecordnum As Integer
intRecordnum = FreeFile
Open "A:/P_SPRDCT.DAT" For Input As #intRecordnum
Do While Not EOF(intRecordnum)
Input #intRecordnum, strProductId, strProductName, curUnitPrice
lstProductId.AddItem strProductId
lstProductName.AddItem strProductName
lstPrice.AddItem curUnitPrice
Loop
Close #intRecordnum
Open "a:/P_SCSTMR.DAT" For Output As #1
Close #1
Open "a:/P_SORDRS.DAT" For Output As #2
Close #2
End Sub
Private Sub VScroll1_Change()
lblAmount.Caption = VScroll1.Value
End Sub
Private Sub lstPrice_Click()
lstPrice.ListIndex = lstProductName.ListIndex
End Sub
Private Sub lstProductId_Click()
lstProductName.ListIndex = lstProductId.ListIndex
lstPrice.ListIndex = lstProductId.ListIndex
End Sub
Private Sub lstProductName_Click()
lstProductId.ListIndex = lstProductName.ListIndex
lstPrice.ListIndex = lstProductName.ListIndex
End Sub
Private Sub optPaymentCode_Click(Index As Integer)
If optPaymentCode(1) = True Then
lblCreditNumber.Caption = InputBox("Please enter your credit card number")
lblMonth.Caption = InputBox("Enter your card's experation month (ie..00)")
lblYear.Caption = InputBox("Enter your card's experation year(ie. 03)")
End If
End Sub
Private Sub vscQuantity_Change()
lblQuantity.Caption = vscQuantity.Value
End Sub