|
-
Nov 21st, 2004, 12:34 AM
#1
Thread Starter
Fanatic Member
pos for windows
Last edited by bob5731; Jan 7th, 2005 at 01:23 AM.
-
Nov 21st, 2004, 12:59 AM
#2
that code looks messed up. Don't you realize that everytime you press a key, the keypress event will fire? What are you trying to do? Also, use VB code tags. Here's how it looks:
Code:
Dim IGap As Integer
Dim QGap As Integer
Dim AGap As Integer
Dim EGap As Integer
Private Type stocktable
descript As String * 24
PRICE As String * 7
-
Nov 21st, 2004, 04:41 PM
#3
You don't have to PM me to get me to read the thread.
You should zip up the project, and the files that it is supposed to be reading, and then maybe we could make some sense of it.
What does it do? What do you want the subtotal of? It looks like the instances of rec.Price are used incorrectly or commented out.
If this program ran at all, it would run 100's of times slower than it should. It is so poorly designed that it isn't worth fixing, if you ask me.
-
Nov 21st, 2004, 04:45 PM
#4
The code might look better if you use the vb code tags.
[ vbcode ]
your code
[ /vbcode ]
With no spaces inside [ ]
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Nov 22nd, 2004, 06:38 PM
#5
Your table appears to be Binary. Try to open it with notepad to see what I mean. The program doesn't read binary files.
Can you get it to do anything? I can't. Maybe if you could get it to a running state, the we could help get subtotals. I don't think that it will ever work right, as its poorly written.
-
Nov 22nd, 2004, 09:45 PM
#6
If your problem has been solved the dont forget to edit your original
post and add the green checkmark as the subject icon or add
Resolved to the post's subject.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 22nd, 2004, 10:16 PM
#7
then your .tbl file was corrupt. I looked at it in Notepad, after stepping through. None of the fields had values, unless it was an unsupported (Non-English) character set.
If you want to try and post it again, I'll take another look.
Do you realize that it is supposed to read 13001 fields here?
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Dim rec As stocktable
Open "c:\pos\bob.tbl" For Random As #1 Len = 120
For X% = 2 To 13001
Get #1, X%, rec
If RTrim$(LTrim$(rec.STOCKNUMBER)) = RTrim$(LTrim$(Text1.Text)) Then
'Label14 = ""
'InputBox "subtotal", subtotal
Text2.Text = rec.PRICE
Text4.Text = rec.descript
'InputBox "subtotal", rec.price
'subtotal = subtotal + rec.PRICE
'Label14 = subtotal
'Print #2, Text2.Text
and that it happens in a keypress routine?
also, why is everything commented out?
To get a sub-total, you have do determine which field you want to use to compute the total, then declare a field (curSubTotal as Currency), and set it to 0 first off, then add to it (curSubTotal = curSubTotal + ???) where ??? is your field.
What do you want the subtotal of? All of the records, or everything for that item, or something else?
When you start the program, what is the first step? (Load File?) or Enter Data somewhere?
-
Nov 22nd, 2004, 11:51 PM
#8
I am trying to fill the list, and when I type the second letter of the description, it adds to the list. I couldn't get any items by number, so I don't know if you want to keep track of the prices that you enter before they get added, and then compute tax and subtotal, or want to loop through the listbox to subtotal the items.
You need to check for CHR(13) Enter in the keypress routine, and then move the data.
Code:
Private Sub flx_KeyPress(KeyAscii As Integer)
If KeyAscii <> 13 Then ' Not Enter
If KeyAscii = 27 Then ' IS Escape
txtInput.Visible = False
Exit Sub
End If
If KeyAscii = 8 Then ' IS BackSpace
tl = Len(txtInput.Text)
If Len(tl) > 0 Then
txtInput.Text = Left(txtInput.Text, tl - 1)
Exit Sub
End If
End If
Else
flx.TextMatrix(flx.Row, flx.Col) = txtInput.Text
txtInput.Visible = False
endif
End Sub
I only add them when the user hits ENTER.
You don't have a tax rate anywhere, but if it's 5%, just multiply the total by .05 to get the tax, or 1.05 to get the total including the tax. (I compute the tax and then add it to the subtotal to get the total.)
Here is some of my calculation code. I'm making Panels.
Code:
txtTotal(4).Text = Format(PanelSubTotal, "$ ##,###.00")
PanelTax = PanelSubTotal * TaxRate
txtTotal(5).Text = Format(PanelTax, "$ ##,###.00")
PanelTotal = PanelSubTotal + PanelTax
txtTotal(6).Text = Format(PanelTotal, "$ ##,###.00")
PanelQuantity = Val(txtTotal(7).Text)
If PanelQuantity <> 0 Then
txtTotal(8).Text = Format(PanelTotal * PanelQuantity, "$ ##,###.00")
Else
txtTotal(8).Text = " Estimate Only "
PanelQuantity = 0
End If
Last edited by dglienna; Nov 23rd, 2004 at 12:02 AM.
-
Nov 23rd, 2004, 01:19 AM
#9
that was code from my app. I didn't change yours. feel free to copy it and modify it for your use.
I was using a textbox that floated OVER the cell. The user types in it, and when he presses Enter, the value is transferred to the flexgrid.
Then, I have a control array of textboxes to keep the totals information.
I still have to transfer the info to one more place (or maybe two - for a summary sheet ) before my app is done. It was 35 pages last month.
I also have option buttons for choices (like taxable, and if the panel is to be assembled)
Last edited by dglienna; Nov 23rd, 2004 at 01:25 AM.
-
Nov 26th, 2004, 12:18 AM
#10
what is the name of the field that you want totalled?
where is it entered, or read?
when do you want the subtotal?
I've already showed you the code that I used to actually do the subtotal and add the tax which gives the total.
ps. just reply back to the thread, and I will see it. no need to email or PM. I won't do the work FOR you, and nobody else will, either. we'll all help you get it working, though.
I don't understand how you managed to get it working. I can't look up any part numbers that exist in the table, but can enter prices and quantities of item that i make up. I don't think that this is what you want/need, though.
tell me which buttons you press, and what you enter (and in what textbox) to get the item to subtotal.
ps - have you read anything that I've posted about the errors?
---- what do you want to do about them?
-
Nov 26th, 2004, 03:29 PM
#11
Code:
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii <> 13 Then
If KeyAscii t= 8 Then ' IS BackSpace
tl = Len(rec.PRICE)
If Len(tl) > 0 Then
Text4.text = Left(Text4.text, tl - 1)
End If
End If
Else
Dim rec As stocktable
Dim STOCKNUMBER As String
Dim a#(60, 4)
Open "c:\pos\bob.tbl" For Random As #1 Len = 120
For X% = 2 To 13001
Get #1, X%, rec
' If rec.???? = Text4.text Then Exit For
' You must use the name of the variable here
Next X%
Close #1
End If
Exit Sub
Here is how the logic should be if you want to read the file to get the part info. Change the IF statement, and then copy the values of .rec to the form.
When you have something that works, post it here. I used your old project, and changed the location of the file. I could only enter one character into the textbox.
-
Nov 26th, 2004, 09:30 PM
#12
Each time you enter a quantity, calculate the total price before you put it up. also, add the total price to the subtotal variable.
when you press the subtotal button, display the value.
when you hit the total button, add the tax to the subtotal to get the total, also.
I got you program to work without generating an error.
It is very confusing, and that's probably why nobody else wanted to get involved.
If you have more problems, then post the project again, because I am deleting it.
-
Nov 26th, 2004, 10:14 PM
#13
create a subtotal field, and use it.
then, print it when you press subtotal. set a flag afterwards.
when you hit total, if you didn't press subtotal, calculate it anyways.
if you used currency data types, then divided everything by 100, you could get things to be formatted.
Code:
format(text1.text."$ ##0.##")
-
Nov 26th, 2004, 10:37 PM
#14
don't you read what I post? forget about the code that I posted. to format, just change the string to what you want.
"####" is for an Integer. Use "$#,###.00" for currency.
you need to print a subtotal line, a tax line, and a total line.
post another version of the project, and I'll look at it again.
-
Nov 26th, 2004, 11:45 PM
#15
I made some changes, for subtotal, tax, and total. i didn't change anything else, though. you'll still want to change things, but I hope that I have gotten you started in the right direction.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|