代码不会弹出客户收据表的文本框中

时间:2013-10-10 20:32:12

标签: vb.net

问题是客户收据表的文本框中不会弹出编码 任何解决方案?

'This is the coding for the for the SelfCheckOutForm. 
'======================================================================================================================================

Option Strict On

'Declare the UPC Structure
Structure UPC
    Friend UPCString As String
    Friend ProductString As String
    Friend DesriptString As String
    Friend WeightDecimal As Decimal
    Friend PriceDecimal As Decimal
End Structure

Public Class SelfCheckout
    'declare structure variables

    Dim PriceArray(4) As UPC
    '====================================================================================================================================
    'declare variables

    Friend TotalPriceDecimal As Decimal
    Friend TotalWeightDecimal As Decimal
    Friend TotalItemsInteger As Integer
    Friend MessageString As String
    Friend totalString As String
    Friend numberOfItemsString As String
    Friend weightOfItemsString As String


    '=======================================================================================================================================
    'ListBox Coding with Arrays
    Private Sub SelfCheckout_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Load My List Box with the UPC Codes
        UPCListBox.Items.Add("12345")
        UPCListBox.Items.Add("23451")
        UPCListBox.Items.Add("34512")
        UPCListBox.Items.Add("45123")
        UPCListBox.Items.Add("51234")
        '-------------------------------------------------------------------------------
        'Create my UPC Array Values
        PriceArray(0).UPCString = "12345"
        PriceArray(1).UPCString = "23451"
        PriceArray(2).UPCString = "34512"
        PriceArray(3).UPCString = "45123"
        PriceArray(4).UPCString = "51234"
        '-------------------------------------------------------------------------------
        'Create my Product Array Values
        PriceArray(0).ProductString = "Computer Tower"
        PriceArray(1).ProductString = "Laptop"
        PriceArray(2).ProductString = "Flatscreen Monitor"
        PriceArray(3).ProductString = "Wifi Router"
        PriceArray(4).ProductString = "All-In-One Printer"
        '------------------------------------------------------------------------------
        'Create my Description Array Variables
        PriceArray(0).DesriptString = "A computer that can do basic office work."
        PriceArray(1).DesriptString = "A computer you can take with you."
        PriceArray(2).DesriptString = "A Computer monitor to go with the tower."
        PriceArray(3).DesriptString = "You can now go online anywhere in your house!"
        PriceArray(4).DesriptString = "It has a Scanner and a fax machine built in!"
        '-------------------------------------------------------------------------------
        'Create my Price Array Values
        PriceArray(0).PriceDecimal = 499.95D
        PriceArray(1).PriceDecimal = 550.5D
        PriceArray(2).PriceDecimal = 170.95D
        PriceArray(3).PriceDecimal = 70.65D
        PriceArray(4).PriceDecimal = 199.95D
        '------------------------------------------------------------------------------
        'Create my Weight Array Values
        PriceArray(0).WeightDecimal = 15
        PriceArray(1).WeightDecimal = 5
        PriceArray(2).WeightDecimal = 8
        PriceArray(3).WeightDecimal = 3
        PriceArray(4).WeightDecimal = 18

    End Sub
    '===============================================================================================================================================

    'Textbox.text from UPC listbox coding
    Private Sub UPCListBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UPCListBox.SelectedIndexChanged
        'Show UPC in UPC TextBox
        UPCTextBox.Text = UPCListBox.Text

        'Looking up the Product
        'Table Look up Do/Loop
        Dim myBoolean As Boolean 'True = Found the Product
        Dim indexInteger As Integer = 0
        Do Until myBoolean Or indexInteger > 4
            With Me
                If UPCTextBox.Text = PriceArray(indexInteger).UPCString Then
                    ProductTextBox.Text = (PriceArray(indexInteger).ProductString) 'Fills Product TextBox
                    DescriptTextBox.Text = (PriceArray(indexInteger).DesriptString) 'Fill Description TextBox
                    WeightTextBox.Text = FormatNumber(PriceArray(indexInteger).WeightDecimal) 'Fill Weight Textbox
                    PriceTextBox.Text = FormatCurrency(PriceArray(indexInteger).PriceDecimal) 'Fill Price Textbox
                    myBoolean = True
                Else
                    indexInteger += 1
                End If
            End With
        Loop

    End Sub
    '====================================================================================================================================================
    'Message Box Coding
    Private Sub PurchaseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PurchaseButton.Click
        If PurchaseButton.Enabled And PriceTextBox.Text <> "" Then
            'Calculate the quantities
            TotalItemsInteger += 1 'counts the purchases made
            TotalPriceDecimal += CDec(PriceTextBox.Text)      'Adds the purchases together
            TotalWeightDecimal += CDec(WeightTextBox.Text)    'Adds the wieghts of purchases together
            '----------------------------------------------------------------------------------------------------------------
            'Building Meassage Box for purchase button
            numberOfItemsString = TotalItemsInteger.ToString()
            totalString = TotalPriceDecimal.ToString("C")
            weightOfItemsString = TotalWeightDecimal.ToString("N")

            MessageString = "Total Items: " & numberOfItemsString &
                Environment.NewLine & "Total Weight: " & weightOfItemsString &
                Environment.NewLine & "Total Price: " & totalString
            '------------------------------------------------------------------------------------------------------------------
            'Display Message box
            MessageBox.Show(MessageString, "Items Purchased:", MessageBoxButtons.OK)

        End If
    End Sub

    Private Sub CloseOrderButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseOrderButton.Click
        CustomerReceiptForm.ShowDialog()
    End Sub
End Class
'Programmer: A.Rose
'Date: 10/8/13
'Description:   The CustomerReceiptForm provides information on how many items, the total weight and price
'of the combined purchase.
'This is The coding for the CustomerReceiptForm.
'===============================================================================================================================================
Option Strict On

Public Class CustomerReceiptForm

    'Function of the Enjoy your Purchase Button
    Private Sub CloseBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseBtn.Click
        Me.Close()
        SelfCheckout.Close()
    End Sub
    '=================================================================================================================================================
    'coding for filling in the Textboxes with the appropriate information
    '-----------------------------------------------------------------------
    'Total Price of Purchases
    Private Sub TotalItemsTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TotalItemsTextBox.TextChanged
        TotalItemsTextBox.Text = SelfCheckout.TotalItemsInteger.ToString()
    End Sub
    '-----------------------------------------------------------------------
    'Total Weight of Purchases
    Private Sub TotalWeightTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TotalWeightTextBox.TextChanged
        TotalWeightTextBox.Text = SelfCheckout.TotalWeightDecimal.ToString("N")
    End Sub
    '------------------------------------------------------------------------
    'Total Price of Purchases
    Private Sub TotalCostTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TotalCostTextBox.TextChanged
        TotalCostTextBox.Text += SelfCheckout.TotalPriceDecimal.ToString("C")
    End Sub
    '-------------------------------------------------------------------------
End Class

1 个答案:

答案 0 :(得分:1)

类就像蓝图一样 - 它们告诉我们什么时候创建它会做什么。这些类的实例实际上就是这些,并且是代码中使用的。你有一个CustomerReceiptForm,但是如果你喜欢这样的话,它就不会显示在任何地方:

    Friend frmCustRec as New CustomerReceiptForm

可能在未发布的代码中的其他位置发生,但此处2类中的引用另有说明。要在CloseOrderButton_Click中将其显示为

    frmCustRec.ShowDialog

SelfCheckout类也是如此 - 你需要一个实例。

顺便说一下,你的UPS结构可以作为一个私人类很好地工作(把它想象成一个SelfCheckout帮助类)。因此,PriceArray可以成为List (Of UPC)Dictionary (of itemKey, UPC),这样可以更轻松地管理和阅读。