Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Here's what I want to do:
* I want to store 3 fields(Item#,Item Name,Unit Price) in a text file. The details should be read into three parallel arrays.* I want to be able to read user input from the keyboard(i.e. not from a text file) using inputbox. The program should ask
CustomerName:
Item#:
Quantity:* Finally the program should display something like the following:
Customer Name: Mr.Bla Bla
Item# | Quantity | Price |SubTotal
007 4 2.00 $8.00
010 1 4.00 $4.00Total: $12.00
I think I need a while statement with a rouge here.
I'd like to tackle this with pure VB not active x. You know--just simple!

==========================================
Option Explicit
Dim fItemNumber(100) As Integer
Dim fItemName(100) As Integer
Dim fUnitPrice(1000) As Integer
Dim fNumRecs As Integer
Dim fCustomerName As String
Dim fQuantity As IntegerPrivate Sub cmdChoose_Click()
Dim i As Integer
i = 0fCustomerName = InputBox("What's your name?")
fItemNumber = InputBox("What's the item number?")
fItemName = InputBox("What's the item name?")
fQuantity = InputBox("How much quantity do you need?")
Open "a:\list.txt" For Input As #1
While Not EOF(1)
i = i + 1
fItemNumber (i), fItemName(i), fUnitPrice(i)
Wend
Close #1
fNumRecs = iEnd Sub
Private Sub cmdPrint_Click()
Dim i As Integer
Dim total As Single
For i = 1 To fNumRecs
Print fCustomerName(i), fItemNumber(i), fItemName(i), fUnitPrice(i),
Print fUnitPrice * fQuantity
Next i
End Sub
==========================================
need help/hints/comments or whatever.....anything appriciated!
===========================================

I'm getting there....any help is accepted
=================================================
Option Explicit
Dim fItemNumber(10) As Integer
Dim fItemName(10) As Integer
Dim fUnitPrice(10) As SinglePrivate Sub cmdChoose_Click()
Dim Customer As String
Dim i As Integer
Dim found As Integer
Dim itemNumber As Integer
i = 0
found = False
'fNumRecs = 1Open "a:\list.txt" For Input As #1
While Not EOF(1)
i = i + 1
Input #1, fItemNumber(i), fItemName(i), fUnitPrice(i)
Close #1Customer = InputBox("What's your name?")
Print (Customer)
Print "=================================="itemNumber = InputBox("What's the item number? (Choose 1-10 inclusive)")
While itemNumber -999
If itemNumber = fItemNumber(i) Then
found = True
Else
i = i + 1
End If
Wend
If found = True Then
Print fItemNumber(i), fItemName(i), fUnitPrice(i)
Else
Print "Item Not On Stock"
End IfWend
End Sub
====================================
in my a:\list , i only have 10 records.
for eg.
1,"coke",1.00
2,"pepsi",1.00
3,"sprite",1.00
.
..
...
10,"dr.pepper",1,00
==============================
also,My while statement seems to be unending.
While itemNumber -999
If itemNumber = fItemNumber(i) Then
found = True
Else
i = i + 1
End If
wendIt prompts me subscript out of range.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |