I have two forms; frmMain & frmReport. I have the following coding for ensuring that the numeric data entered into each of the TextBoxes in in the correct format:
Private Sub btnPurchase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPurchase.Click
txtRef.Text = Format(CInt(txtRef.Text), "000000")
nudProductType.Text = Format(CStr(nudProductType.Text), "0")
txtWeight.Text = Format(CInt(txtWeight.Text), "0000")
txtQuantity.Text = Format(CInt(txtQuantity.Text), "0000")
nudCalcMeth.Text = Format(CStr(nudCalcMeth.Text), "0")
txtBuy.Text = Format(CInt(txtBuy.Text), "0000")
txtSale.Text = Format(CInt(txtSale.Text), "0000")
My first question is that this is VB6 and I would like to know a better way of coding this event process?
Following on from this I then have all the data saved to a string which is then saved to a *txt file:
Private Sub btnPurchase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPurchase.Click
txtRef.Text = Format(CInt(txtRef.Text), "000000")
nudProductType.Text = Format(CStr(nudProductType.Text), "0")
txtWeight.Text = Format(CInt(txtWeight.Text), "0000")
txtQuantity.Text = Format(CInt(txtQuantity.Text), "0000")
nudCalcMeth.Text = Format(CStr(nudCalcMeth.Text), "0")
txtBuy.Text = Format(CInt(txtBuy.Text), "0000")
txtSale.Text = Format(CInt(txtSale.Text), "0000")
Dim TotalSalesFile As String
'put fields together to go to Sales Text File
TotalSalesFile = txtRef.Text & nudProductType.Text _
& txtWeight.Text & txtQuantity.Text & nudCalcMeth.Text _
& txtBuy.Text & txtSale.Text
If MessageBox.Show("Click Yes or No", "Reset", MessageBoxButtons.YesNo) = DialogResult.Yes Then
If MessageBox.Show("Do you wish to clear this purchase?", "Reset", MessageBoxButtons.YesNoCancel) = DialogResult.Yes Then
'Clears existing purchase
txtRef.Text = ""
nudProductType.Text = ""
txtWeight.Text = ""
txtQuantity.Text = ""
nudCalcMeth.Text = ""
txtBuy.Text = ""
txtSale.Text = ""
Else
End If
End If
My second form, frmReport is to read the TotalSalesFile.txt and display the data. My problem here is that I have a NumericUpDown (nudCalcMeth), which has two options (1 or 2) Therefore this is calculated as follows:
My second form has to perfom these calculation when it load and the using Tab print the data. I totaly unsure of how to do this and would very much appreciate someones assistance.
I have included the app in case someone wants to view it and give feedback.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.