Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.66 KB | None | 0 0
  1. Public Class FormAPCalc
  2.  
  3. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  4.  
  5. End Sub
  6.  
  7. Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  8.  
  9. End Sub
  10.  
  11. Private Sub Label12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  12.  
  13. End Sub
  14.  
  15. Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
  16. update_values()
  17. End Sub
  18.  
  19. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  20. AboutAPCalc.Show()
  21. End Sub
  22.  
  23. Private Sub NumericUpDown2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown2.ValueChanged
  24. update_values()
  25. End Sub
  26.  
  27. Private Sub NumericUpDown3_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown3.ValueChanged
  28. update_values()
  29. End Sub
  30.  
  31. Private Sub NumericUpDown4_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown4.ValueChanged
  32. update_values()
  33. End Sub
  34.  
  35. Private Sub NumericUpDown5_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown5.ValueChanged
  36. update_values()
  37. End Sub
  38.  
  39. Private Sub NumericUpDown6_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown6.ValueChanged
  40. update_values()
  41. End Sub
  42.  
  43. Private Sub NumericUpDown7_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown7.ValueChanged
  44. update_values()
  45. End Sub
  46.  
  47. Private Sub NumericUpDown8_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown8.ValueChanged
  48. update_values()
  49. End Sub
  50.  
  51. Private Sub NumericUpDown9_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown9.ValueChanged
  52. update_values()
  53. End Sub
  54.  
  55. Private Sub NumericUpDown10_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown10.ValueChanged
  56. update_values()
  57. End Sub
  58.  
  59. Private Sub NumericUpDown11_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown11.ValueChanged
  60. update_values()
  61. End Sub
  62.  
  63. Private Sub NumericUpDown12_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown12.ValueChanged
  64. update_values()
  65. End Sub
  66.  
  67. Private Sub NumericUpDown13_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown13.ValueChanged
  68. update_values()
  69. End Sub
  70.  
  71. Private Sub NumericUpDown14_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown14.ValueChanged
  72. update_values()
  73. End Sub
  74.  
  75. Private Sub NumericUpDown15_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown15.ValueChanged
  76. update_values()
  77. End Sub
  78.  
  79. Private Sub NumericUpDown16_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown16.ValueChanged
  80. update_values()
  81. End Sub
  82.  
  83. Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
  84.  
  85. End Sub
  86.  
  87. Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
  88. update_values()
  89. End Sub
  90.  
  91. Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
  92.  
  93. End Sub
  94.  
  95. 'LMA: Load the data file.
  96. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  97.  
  98. Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("Data/data.txt")
  99. Dim temp As Integer = 0
  100. Dim is_ok As Boolean = False
  101.  
  102.  
  103. MyReader.TextFieldType = FileIO.FieldType.Delimited
  104. MyReader.SetDelimiters(",")
  105. Dim currentRow As String()
  106. While Not MyReader.EndOfData
  107. Try
  108. temp = 0
  109. currentRow = MyReader.ReadFields()
  110. Dim currentField As String
  111. For Each currentField In currentRow
  112. temp += 1
  113. is_ok = True
  114.  
  115. Select Case temp
  116. Case 1
  117. NumericUpDown1.Value = Val(currentField)
  118.  
  119. Case 2
  120. NumericUpDown2.Value = Val(currentField)
  121.  
  122. Case 3
  123. NumericUpDown3.Value = Val(currentField)
  124.  
  125. Case 4
  126. NumericUpDown4.Value = Val(currentField)
  127.  
  128. Case 5
  129. NumericUpDown5.Value = Val(currentField)
  130.  
  131. Case 6
  132. NumericUpDown6.Value = Val(currentField)
  133.  
  134. Case 7
  135. NumericUpDown7.Value = Val(currentField)
  136.  
  137. Case 8
  138. NumericUpDown8.Value = Val(currentField)
  139.  
  140. Case 9
  141. NumericUpDown9.Value = Val(currentField)
  142.  
  143. Case 10
  144. NumericUpDown10.Value = Val(currentField)
  145.  
  146. Case 11
  147. NumericUpDown11.Value = Val(currentField)
  148.  
  149. Case 12
  150. NumericUpDown12.Value = Val(currentField)
  151.  
  152. Case 13
  153. NumericUpDown13.Value = Val(currentField)
  154.  
  155. Case 14
  156. NumericUpDown14.Value = Val(currentField)
  157.  
  158. Case 15
  159. NumericUpDown15.Value = Val(currentField)
  160.  
  161. Case 16
  162. NumericUpDown16.Value = Val(currentField)
  163.  
  164. Case 17
  165. TextBox2.Text = currentField
  166.  
  167. End Select
  168.  
  169. Next
  170. Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
  171. MsgBox("Problem loading the file!")
  172. End Try
  173. End While
  174.  
  175. If is_ok Then
  176. MsgBox("Ap loaded!")
  177. Else
  178. MsgBox("Nothing to load!")
  179. End If
  180.  
  181. update_values()
  182. End Using
  183.  
  184.  
  185. End Sub
  186.  
  187. 'LMA: Saving button
  188. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  189. Dim temp As String
  190.  
  191. temp = ""
  192. temp += NumericUpDown1.Value.ToString + "," + NumericUpDown2.Value.ToString + "," + NumericUpDown3.Value.ToString + "," + NumericUpDown4.Value.ToString + ","
  193. temp += NumericUpDown5.Value.ToString + "," + NumericUpDown6.Value.ToString + "," + NumericUpDown7.Value.ToString + "," + NumericUpDown8.Value.ToString + ","
  194. temp += NumericUpDown9.Value.ToString + "," + NumericUpDown10.Value.ToString + "," + NumericUpDown11.Value.ToString + "," + NumericUpDown12.Value.ToString + ","
  195. temp += NumericUpDown13.Value.ToString + "," + NumericUpDown14.Value.ToString + "," + NumericUpDown15.Value.ToString + "," + NumericUpDown16.Value.ToString
  196.  
  197. 'personnal AP value.
  198. temp += "," + TextBox2.Text
  199.  
  200. My.Computer.FileSystem.WriteAllText("Data/data.txt", temp, False)
  201.  
  202. MsgBox("Ap Saved!")
  203.  
  204.  
  205.  
  206. End Sub
  207.  
  208. 'LMA: reset button.
  209. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  210. NumericUpDown1.Value = 0
  211. NumericUpDown2.Value = 0
  212. NumericUpDown3.Value = 0
  213. NumericUpDown4.Value = 0
  214.  
  215. NumericUpDown5.Value = 0
  216. NumericUpDown6.Value = 0
  217. NumericUpDown7.Value = 0
  218. NumericUpDown8.Value = 0
  219.  
  220. NumericUpDown9.Value = 0
  221. NumericUpDown10.Value = 0
  222. NumericUpDown11.Value = 0
  223. NumericUpDown12.Value = 0
  224.  
  225. NumericUpDown13.Value = 0
  226. NumericUpDown14.Value = 0
  227. NumericUpDown15.Value = 0
  228. NumericUpDown16.Value = 0
  229.  
  230. TextBox1.Text = ""
  231. TextBox2.Text = ""
  232. TextBox3.Text = ""
  233. End Sub
  234.  
  235. 'LMA: updating values.
  236. Private Sub update_values()
  237. Dim temp As Integer
  238.  
  239. temp += 0
  240. temp += NumericUpDown1.Value * 300
  241. temp += NumericUpDown2.Value * 600
  242. temp += NumericUpDown3.Value * 900
  243. temp += NumericUpDown4.Value * 1200
  244.  
  245. temp += NumericUpDown5.Value * 600
  246. temp += NumericUpDown6.Value * 1200
  247. temp += NumericUpDown7.Value * 1800
  248. temp += NumericUpDown8.Value * 2400
  249.  
  250. temp += NumericUpDown9.Value * 1200
  251. temp += NumericUpDown10.Value * 2400
  252. temp += NumericUpDown11.Value * 3600
  253. temp += NumericUpDown12.Value * 4800
  254.  
  255. temp += NumericUpDown13.Value * 2400
  256. temp += NumericUpDown14.Value * 4800
  257. temp += NumericUpDown15.Value * 7200
  258. temp += NumericUpDown16.Value * 9600
  259.  
  260. TextBox3.Text = temp
  261. TextBox1.Text = Val(TextBox3.Text) + Val(TextBox2.Text)
  262. End Sub
  263.  
  264.  
  265. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement