Welcome Guest ( Log In | Click here to Register a free account now! )
Welcome to Bleeping Computer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.![]() ![]() |
Sep 23 2004, 06:51 PM
Post
#1
|
|
|
Member ![]() ![]() Group: Members Posts: 85 Joined: 30-May 04 Member No.: 617 |
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. This post has been edited by Shibby: Sep 23 2004, 06:52 PM |
|
|
|
Sep 25 2004, 11:05 PM
Post
#2
|
|
![]() Bleep Bleep! ![]() ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 28,967 Joined: 24-January 04 From: USA Member No.: 3 |
Wish I could help you with this....i just dont know VB well enough.
-------------------- Lawrence
|
|
|
|
Oct 16 2004, 04:26 PM
Post
#3
|
|
|
Malware Sniffer ![]() ![]() ![]() ![]() ![]() Group: HJT Team Posts: 757 Joined: 4-September 04 From: West Coast of Scotland Member No.: 2,438 |
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 |
|
|
|
Oct 17 2004, 07:24 AM
Post
#4
|
|
|
Malware Sniffer ![]() ![]() ![]() ![]() ![]() Group: HJT Team Posts: 757 Joined: 4-September 04 From: West Coast of Scotland Member No.: 2,438 |
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 |
|
|
|
![]() ![]() |
| Lo-Fi Version | Time is now: 8th October 2008 - 04:24 AM |