Help - Search - Members - Calendar
Full Version: Need Help
BleepingComputer.com > Software > Programming
   
Shibby
Ok...This is a VB program and i need some help

Check out the pic http://www.miamihost.net/ims/u/Shibby/Pics/untitled.JPG.

What i am trying to do is type in a Quantity (lets say 3) then select my Item (lets say Caps) then when i hit add it will * quantity * the price of caps(9.50) then write that out on the form. I know what spaceing i need and all that but i am not sure how to do this...i have tryed many ways....check my code for one failed attempt. I also want to write it to a running total..(but i think i can do that myself...just need help on this part).

CODE
Private Sub cmdAdd_Click()
   Dim AllData As String
   Dim Product As Integer
   
   AllData = Left(cboSalesman, 5)
   
   'pad Salesman 6 spaces
   AllData = AllData & Space(5 - Len(cboSalesman))

   'pad salesman and school
   AllData = AllData & Space(1 - (optWahs))
   AllData = AllData & Space(1 - (optSahs))
   
   'space between salesman and school
   AllData = AllData & " "
   
   If optWahs = True Then
       AllData = AllData & "West Albany"
   Else
       AllData = AllData & "South Albany"
   End If
   
   AllData = AllData & " "
   
   'Quantity = Val(Quantity)
   
   'If Product("Cap $9.50") = Quantity * 9.5 Then
    '   lstProduct.ListIndex = 0
  ' ElseIf Product("Shirt $8.00") = Quantity * 8# Then
   '    lstProduct.ListIndex = 1
   'ElseIf Product("Jacket $25.75") = Quantity * 25.75 Then
    '   lstProduct.ListIndex = 2
   'End If
   
   
   lstAllData.AddItem AllData
   
   'clear controls
   cboSalesman = ""
   optWahs = False
   optSahs = False
   
   txtQuantity.SetFocus


P.S. this is my 2nd program i have made for a VB class i am taking.
Grinler
Wish I could help you with this....i just dont know VB well enough.
penmore
Hi Shibby,

I'm out of time tonight but will try and have a look tomorrow for you.

It's a wee while since I wrote VB but I'll give it my best shot.

Peter
penmore
Hi Shibby,

I've used basic programming in the past and have used VB but within MS Excel to do some calculations etc behind a form.

Although the example below if from MS Excel I think its the same VB. Each of the fields on your form will have a name, along with the name of the form. In my example the form is named InvDets. All you have to do to get the calculated results into the form is to make the results field on your form = the calculation.

Example:

Private Sub Trade_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If InvDets.Trade <> "" Then
InvDets.Price337 = Format(InvDets.Trade * 1.739, "##0.00")
InvDets.Totprice = Format(InvDets.Price337, "###0.00")
End If
End Sub

All this is doing is when I exit the field on the form named Trade and provided it isn't empty then calculate the fields Price337 and Totprice. You should be able to check up on the Format command to see what that is doing.

I hope this helps you.

Best of luck,
Peter smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.