Guest User

Untitled

a guest
Jul 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 4.49 KB | None | 0 0
  1. Public Class Form1
  2.     Dim Parts(8, 2) As String
  3.     Dim PartsOutput(8, 0) As String
  4.     Dim Column As Integer
  5.     Dim BrandChanged As Boolean
  6.  
  7.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  8.         'Set all the initial Conditions for the UI
  9.         PartNoTxtBox.Clear()
  10.         PartOutputTxtBox.Clear()
  11.  
  12.         PartsOutput(0, 0) = "PR214"
  13.         PartsOutput(1, 0) = "PR223"
  14.         PartsOutput(2, 0) = "PR224"
  15.         PartsOutput(3, 0) = "PR246"
  16.         PartsOutput(4, 0) = "PR247"
  17.         PartsOutput(5, 0) = "PR248"
  18.         PartsOutput(6, 0) = "PR324"
  19.         PartsOutput(7, 0) = "PR326"
  20.         PartsOutput(8, 0) = "PR444"
  21.  
  22.         'Parts list for Brand A
  23.         Parts(0, 0) = "MR43T"
  24.         Parts(1, 0) = "R43"
  25.         Parts(2, 0) = "R43N"
  26.         Parts(3, 0) = "R46N"
  27.         Parts(4, 0) = "R46TS"
  28.         Parts(5, 0) = "R46TX"
  29.         Parts(6, 0) = "S46"
  30.         Parts(7, 0) = "SR46E"
  31.         Parts(8, 0) = "47L"
  32.         'Parts list for Brand B
  33.         Parts(0, 1) = "RBL8"
  34.         Parts(1, 1) = "RJ6"
  35.         Parts(2, 1) = "RN4"
  36.         Parts(3, 1) = "RN8"
  37.         Parts(4, 1) = "RBL17Y"
  38.         Parts(5, 1) = "RBL12-6"
  39.         Parts(6, 1) = "J11"
  40.         Parts(7, 1) = "XEJ8"
  41.         Parts(8, 1) = "H12"
  42.         'Parts list for Brand C
  43.         Parts(0, 2) = "14K22"
  44.         Parts(1, 2) = "14K24"
  45.         Parts(2, 2) = "14K30"
  46.         Parts(3, 2) = "14L32"
  47.         Parts(4, 2) = "14K33"
  48.         Parts(5, 2) = "14K35"
  49.         Parts(6, 2) = "14K38"
  50.         Parts(7, 2) = "14K40"
  51.         Parts(8, 2) = "14K44"
  52.     End Sub
  53.  
  54.     Private Sub BrandARadBtn_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BrandARadBtn.CheckedChanged, BrandBRadBtn.CheckedChanged, BrandCRadBtn.CheckedChanged
  55.  
  56.         BrandChanged = True
  57.  
  58.         If BrandARadBtn.Checked = True Then
  59.             Column = 0
  60.         ElseIf BrandBRadBtn.Checked = True Then
  61.             Column = 1
  62.         ElseIf BrandCRadBtn.Checked = True Then
  63.             Column = 2
  64.         End If
  65.  
  66.     End Sub
  67.  
  68.     Private Sub LookupBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LookupBtn.Click
  69.  
  70.         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.
  71.             For y As Integer = 0 To Column  'Obvious. Finding which brand is chosen.
  72.                 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.
  73.                     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.
  74.                         PartOutputTxtBox.Text = PartsOutput(x, 0)   'More obvious stuff.
  75.                     End If
  76.                 Next
  77.             Next
  78.         Else
  79.             MessageBox.Show("Please select a brand of spark plug.")
  80.         End If
  81.  
  82.     End Sub
  83.  
  84.     Private Sub ClearBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearBtn.Click
  85.         BrandARadBtn.Checked = False
  86.         BrandBRadBtn.Checked = False
  87.         BrandCRadBtn.Checked = False
  88.         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.
  89.         BrandChanged = False    'Boolean variable I used to make sure a radio button was changed.
  90.         PartNoTxtBox.Clear()
  91.         PartOutputTxtBox.Clear()
  92.     End Sub
  93.  
  94.     Private Sub ExitBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitBtn.Click
  95.         Me.Close()
  96.     End Sub
  97.  
  98.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  99.         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.
  100.         Debug.Print(Parts.Length) 'Click this button to find out how I made my solution.
  101.         'It is hidden though but you can see it in UI creation in the design tab. Everyone needs a good debug button.
  102.     End Sub
  103. End Class
Add Comment
Please, Sign In to add comment