Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

PLEASE HELP

we.paynewe.payne Posts: 3Member
Could someone Please look over this code and tell me where I'm going wrong? I cannot get it to read the sequential access file (c:la3.dat) to display on the application or to print out the form using the information written to the file. Please help, I've been stuck on this thing for the past month and I cannot figure out why it will not do what I want it to do.
Option Explicit
Public strInvNum As String, intInvQty As Integer, curUnitPrice As Currency
Private Sub cmdDisplay_Click()
Dim strInvNum As String, intInvCount As Integer, curUnitPrice As Currency, curTotPrice As Currency
Dim intCount As Integer
For intCount = 0 To 4
lblInvCount(1)(intCount).Caption = ""
lblInvCount(2)(intCount).Caption = ""
lblInvCount(3)(intCount).Caption = ""
lblInvCount(4)(intCount).Caption = ""
Next intCount
Open "c:la3.dat" For Input As #1 'open the sequential file
Do While Not EOF(1)
Input #1, intInvCount, curUnitPrice, curTotPrice 'read a record
Select Case strInvNum
Case "ABC12"
lblInvCount(0)(intCount).Caption = Val(txtInvCount.Text) + 1
Case "XYZ35"
lblInvCount(1)(intCount).Caption = Val(txtInvCount.Text) + 1
Case "KLK25"
lblInvCount(2)(intCount).Caption = Val(txtInvCount.Text) + 1
Case "WER10"
lblInvCount(3)(intCount).Caption = Val(txtInvCount.Text) + 1
Case "JAN24"
lblInvCount(4)(intCount).Caption = Val(txtInvCount.Text) + 1
End Select
Loop
Close #1 'close the file

End Sub

Private Sub cmdEnter_Click()
Dim strInvNum As String, intInvCount As Integer, curUnitPrice As Currency
Open "c:la3.dat" For Append As #1 'open the sequential file
Write #1, lstInvNum.Text, txtInvCount.Text, txtUnitPrice.Text 'write the file
Close #1 'close the sequential file



End Sub

Private Sub cmdExit_Click()
End

End Sub

Private Sub cmdPrint_Click()
Dim strInvNum As String, intInvQty As Integer, curUnitPrice As Currency
Dim intABC As Integer, intXYZ As Integer, intKLK As Integer, intWER As Integer, intJAN As Integer
Dim intTotalCount As Integer, curLinePrice As Currency, curTotalprice As Currency, curAvgPrice As Currency
Dim strFont As String, sngSize As Single
Dim strPS1 As String * 3, strPS2 As String * 3, strPS3 As String * 3
Dim strPS4 As String * 3, strPS5 As String * 3, strPS6 As String * 4
Open "c:la3.dat" For Input As #1 'open the sequential file
Do While Not EOF(1)
Input #1, strInvNum, intInvQty, curUnitPrice 'read the file
intTotalCount = intTotalCount + 1 'counter
curLinePrice = Val(intInvQty) * Val(curUnitPrice) 'accumulator
curTotalprice = curTotalprice + curLinePrice
curAvgPrice = curTotalprice / intTotalCount
'accumulate totals
For intTotalCount = 0 To 1000
intABC = intTotalCount + Val(lblABCQty(1).Caption)
intXYZ = intTotalCount + Val(lblXYZQty(2).Caption)
intKLK = intTotalCount + Val(lblKLKQty(3).Caption)
intWER = intTotalCount + Val(lblWERQty(4).Caption)
intJAN = intTotalCount + Val(lblJANQty(5).Caption)
Next intTotalCount
intTotalCount = intABC + intXYZ + intKLK + intWER + intJAN
Loop


strFont = Printer.Font 'save current printer settings
sngSize = Printer.FontSize
Printer.Font = "Times New Roman" 'change printer settings
Printer.FontSize = 10 'print title and heading
Printer.Print Tab(31); "BOGGS INC. INVENTORY LIST"
Printer.Print
Printer.Print
Printer.Print Tab(5); "Catalog Number"; Tab(25); "Quantity"; Tab(36); "Price"; Tab(47); "Total Price"

'align ABC12 numbers and print
RSet strPS1 = Format(lblABCQty(1).Caption, "general Number")
RSet strPS2 = Format(lblABCPrice(1).Caption, "currency")
RSet strPS3 = Format(lblTotalPrice(0).Caption, "Currency")
RSet strPS4 = Format(curTotalprice, "currency")
Printer.Print Tab(5); "ABC12"; Tab(20); strPS1; Tab(31); strPS2; Tab(40); strPS3
'align XYZ35 numbers and print
RSet strPS1 = Format(lblXYZQty(2).Caption, "general Number")
RSet strPS2 = Format(lblXYZPrice(2).Caption, "currency")
RSet strPS3 = Format(lblTotalPrice(1).Caption, "Currency")
RSet strPS4 = Format(curTotalprice, "currency")
Printer.Print Tab(5); "XYZ35"; Tab(20); strPS1; Tab(31); strPS2; Tab(40); strPS3
'align KLK25 numbers and print
RSet strPS1 = Format(lblKLKQty(3).Caption, "general Number")
RSet strPS2 = Format(lblKLKPrice(3).Caption, "currency")
RSet strPS3 = Format(lblTotalPrice(2).Caption, "Currency")
RSet strPS4 = Format(curTotalprice, "currency")
Printer.Print Tab(5); "KLK25"; Tab(20); strPS1; Tab(31); strPS2; Tab(40); strPS3
'align WER10 numbers and print
RSet strPS1 = Format(lblWERQty(4).Caption, "general Number")
RSet strPS2 = Format(lblWERPrice(4).Caption, "currency")
RSet strPS3 = Format(lblTotalPrice(3).Caption, "Currency")
RSet strPS4 = Format(curTotalprice, "currency")
Printer.Print Tab(5); "WER10"; Tab(20); strPS1; Tab(31); strPS2; Tab(40); strPS3
'align JAN24 numbers and print
RSet strPS1 = Format(lblJANQty(5).Caption, "general Number")
RSet strPS2 = Format(lblJANPrice(5).Caption, "currency")
RSet strPS3 = Format(lblTotalPrice(0).Caption, "Currency")
RSet strPS4 = Format(curTotalprice, "currency")
Printer.Print Tab(5); "JAN24"; Tab(20); strPS1; Tab(31); strPS2; Tab(40); strPS3
'print grand totals
RSet strPS5 = Format(intTotalCount, "general number")
RSet strPS5 = Format(curTotalprice, "currency")
RSet strPS5 = Format(curAvgPrice, "currency")
Printer.Print Tab(20); "Grand Total"; Tab(36); "Total Price"; Tab(60); "Average Price"
Printer.Print 'print two blank lines
Printer.Print
Printer.Print Tab(5); "End of Report" 'print message
Printer.EndDoc 'send report to printer
Printer.Font = strFont
Printer.FontSize = sngSize


End Sub

Private Sub Form_Load()
lstInvNum.AddItem "ABC12"
lstInvNum.AddItem "XYZ35"
lstInvNum.AddItem "KLK25"
lstInvNum.AddItem "WER10"
lstInvNum.AddItem "JAN24"
lstInvNum.ListIndex = 0

End Sub

Private Sub Label14_Click(Index As Integer)

End Sub

Private Sub Mnu_exit_Click()
End

End Sub


Comments

  • lionblionb Posts: 1,686Member
    : Could someone Please look over this code and tell me where I'm going wrong? I cannot get it to read the sequential access file (c:la3.dat) to display on the application or to print out the form using the information written to the file. Please help, I've been stuck on this thing for the past month and I cannot figure out why it will not do what I want it to do.
    [code]
    Option Explicit
    Public strInvNum As String, intInvQty As Integer, curUnitPrice As Currency
    Private Sub cmdDisplay_Click()
    Dim strInvNum As String, intInvCount As Integer, curUnitPrice As Currency, curTotPrice As Currency
    Dim intCount As Integer
    For intCount = 0 To 4
    [blue]lblInvCount[b](1)[/b](intCount).Caption = ""[/blue]
    : .....
    Select Case strInvNum
    Case "ABC12"
    [blue]lblInvCount[b](0)[/b](intCount).Caption = Val(txtInvCount.Text) + 1 [/blue]
    [/code]
    I do not understand what you are doing here but I think your problem is here
    [code]
    lblInvCount[b](1)[/b](intCount).Caption =""
    lblInvCount[b](0)[/b](intCount).Caption = Val(txtInvCount.Text) + 1
    [/code]
    I belive it shoud be something like that
    [code]
    lblInvCount(intCount).Caption = ""
    lblInvCount(intCount).Caption = Val(txtInvCount.Text) + 1
    [/code]
  • alfy2171alfy2171 Posts: 1Member
    Did you get this to work? I'm having the same problem too.

    : : Could someone Please look over this code and tell me where I'm going wrong? I cannot get it to read the sequential access file (c:la3.dat) to display on the application or to print out the form using the information written to the file. Please help, I've been stuck on this thing for the past month and I cannot figure out why it will not do what I want it to do.
    : [code]
    : Option Explicit
    : Public strInvNum As String, intInvQty As Integer, curUnitPrice As Currency
    : Private Sub cmdDisplay_Click()
    : Dim strInvNum As String, intInvCount As Integer, curUnitPrice As Currency, curTotPrice As Currency
    : Dim intCount As Integer
    : For intCount = 0 To 4
    : [blue]lblInvCount[b](1)[/b](intCount).Caption = ""[/blue]
    : : .....
    : Select Case strInvNum
    : Case "ABC12"
    : [blue]lblInvCount[b](0)[/b](intCount).Caption = Val(txtInvCount.Text) + 1 [/blue]
    : [/code]
    : I do not understand what you are doing here but I think your problem is here
    : [code]
    : lblInvCount[b](1)[/b](intCount).Caption =""
    : lblInvCount[b](0)[/b](intCount).Caption = Val(txtInvCount.Text) + 1
    : [/code]
    : I belive it shoud be something like that
    : [code]
    : lblInvCount(intCount).Caption = ""
    : lblInvCount(intCount).Caption = Val(txtInvCount.Text) + 1
    : [/code]
    :

Sign In or Register to comment.