Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Dim Parts(8, 2) As String
- Dim PartsOutput(8, 0) As String
- Dim Column As Integer
- Dim BrandChanged As Boolean
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'Set all the initial Conditions for the UI
- PartNoTxtBox.Clear()
- PartOutputTxtBox.Clear()
- PartsOutput(0, 0) = "PR214"
- PartsOutput(1, 0) = "PR223"
- PartsOutput(2, 0) = "PR224"
- PartsOutput(3, 0) = "PR246"
- PartsOutput(4, 0) = "PR247"
- PartsOutput(5, 0) = "PR248"
- PartsOutput(6, 0) = "PR324"
- PartsOutput(7, 0) = "PR326"
- PartsOutput(8, 0) = "PR444"
- 'Parts list for Brand A
- Parts(0, 0) = "MR43T"
- Parts(1, 0) = "R43"
- Parts(2, 0) = "R43N"
- Parts(3, 0) = "R46N"
- Parts(4, 0) = "R46TS"
- Parts(5, 0) = "R46TX"
- Parts(6, 0) = "S46"
- Parts(7, 0) = "SR46E"
- Parts(8, 0) = "47L"
- 'Parts list for Brand B
- Parts(0, 1) = "RBL8"
- Parts(1, 1) = "RJ6"
- Parts(2, 1) = "RN4"
- Parts(3, 1) = "RN8"
- Parts(4, 1) = "RBL17Y"
- Parts(5, 1) = "RBL12-6"
- Parts(6, 1) = "J11"
- Parts(7, 1) = "XEJ8"
- Parts(8, 1) = "H12"
- 'Parts list for Brand C
- Parts(0, 2) = "14K22"
- Parts(1, 2) = "14K24"
- Parts(2, 2) = "14K30"
- Parts(3, 2) = "14L32"
- Parts(4, 2) = "14K33"
- Parts(5, 2) = "14K35"
- Parts(6, 2) = "14K38"
- Parts(7, 2) = "14K40"
- Parts(8, 2) = "14K44"
- End Sub
- Private Sub BrandARadBtn_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BrandARadBtn.CheckedChanged, BrandBRadBtn.CheckedChanged, BrandCRadBtn.CheckedChanged
- BrandChanged = True
- If BrandARadBtn.Checked = True Then
- Column = 0
- ElseIf BrandBRadBtn.Checked = True Then
- Column = 1
- ElseIf BrandCRadBtn.Checked = True Then
- Column = 2
- End If
- End Sub
- Private Sub LookupBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LookupBtn.Click
- If BrandChanged = True Then 'Just want to make sure the user clicks the radio buttons to foce the Radio button sub routine to play, and change the value of the column variable.
- For y As Integer = 0 To Column 'Obvious. Finding which brand is chosen.
- For x As Integer = 0 To Parts.Length - (Parts.Length - 8) ' Using the debug tool, I found that array.length is going to be the number of values contained in the array. I only needed the range of one column, so I took the length and subtracted it by its self minus the size of the column lenght. It goes out of range if I dont, so - 1 always failed to work.
- If PartNoTxtBox.Text.ToUpper = Parts(x, y).ToString Then 'If I did not provide the above solution, this is the line that would error, because it was trying to use the variable y when it was WAY out of size for it.
- PartOutputTxtBox.Text = PartsOutput(x, 0) 'More obvious stuff.
- End If
- Next
- Next
- Else
- MessageBox.Show("Please select a brand of spark plug.")
- End If
- End Sub
- Private Sub ClearBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearBtn.Click
- BrandARadBtn.Checked = False
- BrandBRadBtn.Checked = False
- BrandCRadBtn.Checked = False
- Column = -1 'Only here because I want the column variable to change Keeping it > 0 would be bad because those are all potential column lenghts.
- BrandChanged = False 'Boolean variable I used to make sure a radio button was changed.
- PartNoTxtBox.Clear()
- PartOutputTxtBox.Clear()
- End Sub
- Private Sub ExitBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitBtn.Click
- Me.Close()
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Debug.Print(Parts.Length - 1) 'When I got home, I tried to run it to make it work the way I planned, but I ran into problems.
- Debug.Print(Parts.Length) 'Click this button to find out how I made my solution.
- 'It is hidden though but you can see it in UI creation in the design tab. Everyone needs a good debug button.
- End Sub
- End Class
Add Comment
Please, Sign In to add comment