2013-10-10 3 views
0

Проблема заключается в том, что кодировка не будет отображаться в текстовых блоках формы получения Клиента.
Любые решения?Код не отображается в текстовом поле формы получения от клиента

'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

Классы как чертежи - они говорят, что что-то будет делать, когда (если) она когда-либо созданных. Экземпляры этих классов действительно делают эти вещи и являются тем, что используется в коде. У вас есть CustomerReceiptForm но не отображается в любом месте, что вы когда-либо создал экземпляр, если это так:

Friend frmCustRec as New CustomerReceiptForm 

ВОЗМОЖНО, что происходит в других местах в коде не писал, но ссылки в 2-х классах здесь указано иное. Для того, чтобы показать, как в CloseOrderButton_Click было бы

frmCustRec.ShowDialog 

То же самое верно, то SelfCheckout класс - вам нужен экземпляр.

BTW, ваша структура UPS будет работать отлично как частный класс (подумайте об этом как о классе помощника SelfCheckout). Таким образом, PriceArray может стать List (Of UPC) или Dictionary (of itemKey, UPC), что упростит управление и чтение.

Смежные вопросы