Problem Incrementing a Purchase Order Number

May 1, 2011 at 15:30:40
Specs: Windows 7
I am having a problem incrementing a purchase order ID in Visual Basic 2008 Express Edition. The number has to automatically increment each time the user clicks the Add button and that number needs to display in a read-only textbox. I'm not sure if a label is the best way to display read-only data. Also, I created a PO class that the frmAddPO references. I'm unsure of what I'm missing and how I need to code this. Additionally, I created a dynamic purchase order array on form1, the controlling form, which alleviates the need for counter variables. I am new to VB, so I've been learning as I go. Any help would be greatly appreciated. Thank you in advance. The code is as follows:


Public Class Form1
Public employee As New List(Of emp)
Public paychecks As New List(Of paycheck)
Public timecards As New List(Of timecard)
Public purchaseOrders As New List(Of PO)
'Public emp_cntr As Integer
'Public pay_cntr As Integer
'Public time_cntr As Integer
'Public po_cntr As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim admin As New salaried_emp(4)
Dim splash As New AcmeSplashScreen
employee.Add(admin)
'emp_cntr += 1

Dim emp1 As New comm_emp
employee.Add(emp1)
'emp_cntr += 1

Dim emp2 As New hourly_emp
employee.Add(emp2)
'emp_cntr += 1

Dim emp4 As New salaried_emp
employee.Add(emp4)
'emp_cntr += 1

Me.Hide()
splash.ShowDialog()
End Sub
End Class
_________________________________________________________________________

Public Class frmAddPO
Private Sub frmAddPO_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Dim i As Integer

'txtPOid.Text = CStr(0)
End Sub

Private Sub btnAddPO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddPO.Click
Dim po As New PO

'For i = 0 To Form1.purchaseOrders.Count - 1
'Dim po_id As Integer = 0
'po_id = po_id + 1
'txtPOC.Text = po.GetSetPOid.ToString
'Next

'po.GetSetPOid = CInt(txtPOid.Text)
po.GetSetEmpID = CInt(txtEmpID.Text)
po.GetSetOrderDate = mtxtOrderDate.Text
po.GetSetPointOfContact = txtPOC.Text
po.GetSetBillingAddress = txtBillingAddr.Text
po.GetSetProductPurchases = txtPurchases.Text
Form1.purchaseOrders.Add(po)
End Sub
End Class

_______________________________________________________________________

Public Class PO
Private PO_id As Integer
Private empID As Integer
Private pointOfContact As String
Private billingAddress As String
Private productPurchases As String
Private orderDate As String

Public Property GetSetPointOfContact() As String
Get
Return pointOfContact
End Get
Set(ByVal value As String)
pointOfContact = value
End Set
End Property

Public Property GetSetBillingAddress() As String
Get
Return billingAddress
End Get
Set(ByVal value As String)
billingAddress = value
End Set
End Property

Public Property GetSetProductPurchases() As String
Get
Return productPurchases
End Get
Set(ByVal value As String)
productPurchases = value
End Set
End Property

Public Property GetSetOrderDate() As String
Get
Return orderDate
End Get
Set(ByVal value As String)
orderDate = value
End Set
End Property

Public Property GetSetPOid() As Integer
Get
Return PO_id
End Get
Set(ByVal value As Integer)
PO_id = value
End Set
End Property

Public Property GetSetEmpID() As Integer
Get
Return empID
End Get
Set(ByVal value As Integer)
empID = value
End Set
End Property

Public Function getPO()
NOT SURE IF I NEED THIS FUNCTION OR NOT
End Function
End Class


See More: Problem Incrementing a Purchase Order Number

Report •

#1
May 2, 2011 at 06:19:13
I'm not sure if a label is the best way to display read-only data.
It's your call. Typically, I'd either display it in a disabled TextBox, a label, or not at all, but that's far from the only option.

I am having a problem incrementing a purchase order ID in Visual Basic 2008 Express Edition.
Assuming you're dumping this data into some database, get the next number from the database. It's the database' s job to manage the data, so let it do its job.

How To Ask Questions The Smart Way


Report •

#2
May 2, 2011 at 07:32:36
Thank you for your response. The ID number has to be displayed after hitting the Add button, so I will just stick to the textbox. This program isn't using a db; dynamic arrays are being used to hold/retrieve the data, so I need to code a counter to increment the purchase order ID number each time a purchase order added.

The only information that is required to be entered by the user is an employee ID, order date, point of contact, billing address, and product purchases. After the user clicks the Add button, then a PO ID # needs to be automatically assigned via the dynamic arrays.


Report •

#3
May 2, 2011 at 07:37:35
If you're using a dynamic array (instead of something sane like List(Of T)), just call UBound. That'll tell you the upper bound of your array.

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question