toksoladuti
IS-IT--Management
I'm very new to visual basic 2008 and could do with a helping hand. I've created a small windows form app with a Combobox (dropdownlist) where users can select a pre-entered productgroup. There is a TextBox where they can enter a quantity, a Label for results and finally a generate Button.
At the moment, I've generated the code below, which allows me select a product, click the button and it prints a random generated productcode to the Label. I'd actually like to click the button and it create as many random product codes as the number entered in the quantity TextBox. I'd also want the numbers to unique and thus the app reference a row called "productcode" in a database table called "product". Any pointers or help would be greatly appreciated.
Current code:
Public Class Form1
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
Private Sub selectComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles selectComboBox.SelectedIndexChanged
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub generateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles generateButton.Click
Dim pcprefix As Integer
Dim qty As Integer
qty = quantityTextBox.Text
Select Case selectComboBox.Text
Case "01 Adhesives"
pcprefix = 20100000 + (New Random).Next(10000, 99999)
Case "02 Brackets"
pcprefix = 20200000 + (New Random).Next(10000, 99999)
Case "03 Bolts"
pcprefix = 20300000 + (New Random).Next(10000, 99999)
Case "04 Chipboard"
pcprefix = 20400000 + (New Random).Next(10000, 99999)
Case "05 Contiboard"
pcprefix = 20500000 + (New Random).Next(10000, 99999)
Case "06 Cupboard Doors"
pcprefix = 20600000 + (New Random).Next(10000, 99999)
Case "07 Cut To Size"
pcprefix = 20700000 + (New Random).Next(10000, 99999)
Case "08 Decorative Boards"
pcprefix = 20800000 + (New Random).Next(10000, 99999)
Case "09 Decorators Aids"
pcprefix = 20900000 + (New Random).Next(10000, 99999)
Case "10 Doors"
pcprefix = 21000000 + (New Random).Next(10000, 99999)
End Select
resultLabel.Text = pcprefix
End Sub
Private Sub resultLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles resultLabel.Click
End Sub
End Class
Thanks.
At the moment, I've generated the code below, which allows me select a product, click the button and it prints a random generated productcode to the Label. I'd actually like to click the button and it create as many random product codes as the number entered in the quantity TextBox. I'd also want the numbers to unique and thus the app reference a row called "productcode" in a database table called "product". Any pointers or help would be greatly appreciated.
Current code:
Public Class Form1
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
Private Sub selectComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles selectComboBox.SelectedIndexChanged
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub generateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles generateButton.Click
Dim pcprefix As Integer
Dim qty As Integer
qty = quantityTextBox.Text
Select Case selectComboBox.Text
Case "01 Adhesives"
pcprefix = 20100000 + (New Random).Next(10000, 99999)
Case "02 Brackets"
pcprefix = 20200000 + (New Random).Next(10000, 99999)
Case "03 Bolts"
pcprefix = 20300000 + (New Random).Next(10000, 99999)
Case "04 Chipboard"
pcprefix = 20400000 + (New Random).Next(10000, 99999)
Case "05 Contiboard"
pcprefix = 20500000 + (New Random).Next(10000, 99999)
Case "06 Cupboard Doors"
pcprefix = 20600000 + (New Random).Next(10000, 99999)
Case "07 Cut To Size"
pcprefix = 20700000 + (New Random).Next(10000, 99999)
Case "08 Decorative Boards"
pcprefix = 20800000 + (New Random).Next(10000, 99999)
Case "09 Decorators Aids"
pcprefix = 20900000 + (New Random).Next(10000, 99999)
Case "10 Doors"
pcprefix = 21000000 + (New Random).Next(10000, 99999)
End Select
resultLabel.Text = pcprefix
End Sub
Private Sub resultLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles resultLabel.Click
End Sub
End Class
Thanks.