login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > Overige > VBScript > Rekenmachine

Rekenmachine

Auteur: GTW - 24 september 2006 - 10:22 - Gekeurd door: Joel - Hits: 6674 - Aantal punten: 3.20 (5 stemmen)





Bij dit script ga ik ervan uit dat Visual Studio wordt gebruikt. Tenzij anders, weet je vast wel hoe de mappen en bestanden heten ;)
Maak een nieuw project aan en doe bestand->save all.
Ga nu in explorer naar de map waar het opgeslagen wordt. (standaard is dat een map in "mijn Documenten", tenzij anders ingesteld. Ga dan naar die map.)
In de map projects naar het zojuist aangemaakte project. Ga dan naar de enige andere map in die map (zelfde naam als de vorige map).
Open dan Form1.designer.vb in klasblok en vervang alles in dat bestand door de code hieronder.
Doe hetzelfde met Form1.vb.

Als je nu het programma wilt gebruiken als .exe moet je in Visual Studio via het menu "build" de functie "Build 'naam'" gebruiken. Nu staat het .exe bestand in de map waar we net waren in de map "obj/release".
Dit bestand staat er samen met andere bestanden maar kan zeker wel alleen worden gebruikt.

Veel plezier met het rekenen.

GTW

Code:
---Form1.designer.vb---
  1. <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
  2. Partial Class Form1
  3. Inherits System.Windows.Forms.Form
  4.  
  5. 'Form overrides dispose to clean up the component list.
  6. <System.Diagnostics.DebuggerNonUserCode()> _
  7. Protected Overrides Sub Dispose(ByVal disposing As Boolean)
  8. If disposing AndAlso components IsNot Nothing Then
  9. components.Dispose()
  10. End If
  11. MyBase.Dispose(disposing)
  12. End Sub
  13.  
  14. 'Required by the Windows Form Designer
  15. Private components As System.ComponentModel.IContainer
  16.  
  17. 'NOTE: The following procedure is required by the Windows Form Designer
  18. 'It can be modified using the Windows Form Designer.
  19. 'Do not modify it using the code editor.
  20. <System.Diagnostics.DebuggerStepThrough()> _
  21. Private Sub InitializeComponent()
  22. Me.uitkomst = New System.Windows.Forms.TextBox
  23. Me.Button1 = New System.Windows.Forms.Button
  24. Me.Button2 = New System.Windows.Forms.Button
  25. Me.Button3 = New System.Windows.Forms.Button
  26. Me.Button4 = New System.Windows.Forms.Button
  27. Me.Button5 = New System.Windows.Forms.Button
  28. Me.Button6 = New System.Windows.Forms.Button
  29. Me.Button7 = New System.Windows.Forms.Button
  30. Me.Button8 = New System.Windows.Forms.Button
  31. Me.Button9 = New System.Windows.Forms.Button
  32. Me.Button0 = New System.Windows.Forms.Button
  33. Me.Buttonc = New System.Windows.Forms.Button
  34. Me.Buttoncalc = New System.Windows.Forms.Button
  35. Me.Buttonplus = New System.Windows.Forms.Button
  36. Me.Buttonmin = New System.Windows.Forms.Button
  37. Me.Buttondelen = New System.Windows.Forms.Button
  38. Me.Buttonmaal = New System.Windows.Forms.Button
  39. Me.SuspendLayout()
  40. '
  41. 'uitkomst
  42. '
  43. Me.uitkomst.Location = New System.Drawing.Point(29, 12)
  44. Me.uitkomst.Name = "uitkomst"
  45. Me.uitkomst.RightToLeft = System.Windows.Forms.RightToLeft.Yes
  46. Me.uitkomst.Size = New System.Drawing.Size(161, 20)
  47. Me.uitkomst.TabIndex = 60
  48. Me.uitkomst.TabStop = False
  49. Me.uitkomst.Text = "0"
  50. '
  51. 'Button1
  52. '
  53. Me.Button1.Location = New System.Drawing.Point(29, 56)
  54. Me.Button1.Name = "Button1"
  55. Me.Button1.Size = New System.Drawing.Size(34, 23)
  56. Me.Button1.TabIndex = 0
  57. Me.Button1.Text = "1"
  58. Me.Button1.UseVisualStyleBackColor = True
  59. '
  60. 'Button2
  61. '
  62. Me.Button2.Location = New System.Drawing.Point(90, 56)
  63. Me.Button2.Name = "Button2"
  64. Me.Button2.Size = New System.Drawing.Size(34, 23)
  65. Me.Button2.TabIndex = 2
  66. Me.Button2.Text = "2"
  67. Me.Button2.UseVisualStyleBackColor = True
  68. '
  69. 'Button3
  70. '
  71. Me.Button3.Location = New System.Drawing.Point(153, 56)
  72. Me.Button3.Name = "Button3"
  73. Me.Button3.Size = New System.Drawing.Size(37, 23)
  74. Me.Button3.TabIndex = 3
  75. Me.Button3.Text = "3"
  76. Me.Button3.UseVisualStyleBackColor = True
  77. '
  78. 'Button4
  79. '
  80. Me.Button4.Location = New System.Drawing.Point(29, 85)
  81. Me.Button4.Name = "Button4"
  82. Me.Button4.Size = New System.Drawing.Size(34, 23)
  83. Me.Button4.TabIndex = 4
  84. Me.Button4.Text = "4"
  85. Me.Button4.UseVisualStyleBackColor = True
  86. '
  87. 'Button5
  88. '
  89. Me.Button5.Location = New System.Drawing.Point(90, 85)
  90. Me.Button5.Name = "Button5"
  91. Me.Button5.Size = New System.Drawing.Size(34, 23)
  92. Me.Button5.TabIndex = 5
  93. Me.Button5.Text = "5"
  94. Me.Button5.UseVisualStyleBackColor = True
  95. '
  96. 'Button6
  97. '
  98. Me.Button6.Location = New System.Drawing.Point(153, 85)
  99. Me.Button6.Name = "Button6"
  100. Me.Button6.Size = New System.Drawing.Size(37, 23)
  101. Me.Button6.TabIndex = 6
  102. Me.Button6.Text = "6"
  103. Me.Button6.UseVisualStyleBackColor = True
  104. '
  105. 'Button7
  106. '
  107. Me.Button7.Location = New System.Drawing.Point(29, 114)
  108. Me.Button7.Name = "Button7"
  109. Me.Button7.Size = New System.Drawing.Size(34, 23)
  110. Me.Button7.TabIndex = 7
  111. Me.Button7.Text = "7"
  112. Me.Button7.UseVisualStyleBackColor = True
  113. '
  114. 'Button8
  115. '
  116. Me.Button8.Location = New System.Drawing.Point(90, 114)
  117. Me.Button8.Name = "Button8"
  118. Me.Button8.Size = New System.Drawing.Size(34, 23)
  119. Me.Button8.TabIndex = 8
  120. Me.Button8.Text = "8"
  121. Me.Button8.UseVisualStyleBackColor = True
  122. '
  123. 'Button9
  124. '
  125. Me.Button9.Location = New System.Drawing.Point(153, 114)
  126. Me.Button9.Name = "Button9"
  127. Me.Button9.Size = New System.Drawing.Size(37, 23)
  128. Me.Button9.TabIndex = 9
  129. Me.Button9.Text = "9"
  130. Me.Button9.UseVisualStyleBackColor = True
  131. '
  132. 'Button0
  133. '
  134. Me.Button0.Location = New System.Drawing.Point(90, 143)
  135. Me.Button0.Name = "Button0"
  136. Me.Button0.Size = New System.Drawing.Size(34, 23)
  137. Me.Button0.TabIndex = 10
  138. Me.Button0.Text = "0"
  139. Me.Button0.UseVisualStyleBackColor = True
  140. '
  141. 'Buttonc
  142. '
  143. Me.Buttonc.Location = New System.Drawing.Point(29, 143)
  144. Me.Buttonc.Name = "Buttonc"
  145. Me.Buttonc.Size = New System.Drawing.Size(34, 23)
  146. Me.Buttonc.TabIndex = 11
  147. Me.Buttonc.Text = "C"
  148. Me.Buttonc.UseVisualStyleBackColor = True
  149. '
  150. 'Buttoncalc
  151. '
  152. Me.Buttoncalc.Location = New System.Drawing.Point(153, 143)
  153. Me.Buttoncalc.Name = "Buttoncalc"
  154. Me.Buttoncalc.Size = New System.Drawing.Size(37, 23)
  155. Me.Buttoncalc.TabIndex = 12
  156. Me.Buttoncalc.Text = "="
  157. Me.Buttoncalc.UseVisualStyleBackColor = True
  158. '
  159. 'Buttonplus
  160. '
  161. Me.Buttonplus.Location = New System.Drawing.Point(12, 172)
  162. Me.Buttonplus.Name = "Buttonplus"
  163. Me.Buttonplus.Size = New System.Drawing.Size(36, 23)
  164. Me.Buttonplus.TabIndex = 13
  165. Me.Buttonplus.Text = "+"
  166. Me.Buttonplus.UseVisualStyleBackColor = True
  167. '
  168. 'Buttonmin
  169. '
  170. Me.Buttonmin.Location = New System.Drawing.Point(69, 172)
  171. Me.Buttonmin.Name = "Buttonmin"
  172. Me.Buttonmin.Size = New System.Drawing.Size(36, 23)
  173. Me.Buttonmin.TabIndex = 14
  174. Me.Buttonmin.Text = "-"
  175. Me.Buttonmin.UseVisualStyleBackColor = True
  176. '
  177. 'Buttondelen
  178. '
  179. Me.Buttondelen.Location = New System.Drawing.Point(121, 172)
  180. Me.Buttondelen.Name = "Buttondelen"
  181. Me.Buttondelen.Size = New System.Drawing.Size(40, 23)
  182. Me.Buttondelen.TabIndex = 15
  183. Me.Buttondelen.Text = "/"
  184. Me.Buttondelen.UseVisualStyleBackColor = True
  185. '
  186. 'Buttonmaal
  187. '
  188. Me.Buttonmaal.Location = New System.Drawing.Point(177, 172)
  189. Me.Buttonmaal.Name = "Buttonmaal"
  190. Me.Buttonmaal.Size = New System.Drawing.Size(36, 23)
  191. Me.Buttonmaal.TabIndex = 16
  192. Me.Buttonmaal.Text = "*"
  193. Me.Buttonmaal.UseVisualStyleBackColor = True
  194. '
  195. 'Form1
  196. '
  197. Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
  198. Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
  199. Me.ClientSize = New System.Drawing.Size(225, 203)
  200. Me.Controls.Add(Me.Buttonmaal)
  201. Me.Controls.Add(Me.Buttondelen)
  202. Me.Controls.Add(Me.Buttonmin)
  203. Me.Controls.Add(Me.Buttonplus)
  204. Me.Controls.Add(Me.Buttoncalc)
  205. Me.Controls.Add(Me.Buttonc)
  206. Me.Controls.Add(Me.Button0)
  207. Me.Controls.Add(Me.Button9)
  208. Me.Controls.Add(Me.Button8)
  209. Me.Controls.Add(Me.Button7)
  210. Me.Controls.Add(Me.Button6)
  211. Me.Controls.Add(Me.Button5)
  212. Me.Controls.Add(Me.Button4)
  213. Me.Controls.Add(Me.Button3)
  214. Me.Controls.Add(Me.Button2)
  215. Me.Controls.Add(Me.Button1)
  216. Me.Controls.Add(Me.uitkomst)
  217. Me.MaximizeBox = False
  218. Me.MinimizeBox = False
  219. Me.Name = "Form1"
  220. Me.Text = "Rekenmachine"
  221. Me.ResumeLayout(False)
  222. Me.PerformLayout()
  223.  
  224. End Sub
  225. Friend WithEvents uitkomst As System.Windows.Forms.TextBox
  226. Friend WithEvents Button1 As System.Windows.Forms.Button
  227. Friend WithEvents Button2 As System.Windows.Forms.Button
  228. Friend WithEvents Button3 As System.Windows.Forms.Button
  229. Friend WithEvents Button4 As System.Windows.Forms.Button
  230. Friend WithEvents Button5 As System.Windows.Forms.Button
  231. Friend WithEvents Button6 As System.Windows.Forms.Button
  232. Friend WithEvents Button7 As System.Windows.Forms.Button
  233. Friend WithEvents Button8 As System.Windows.Forms.Button
  234. Friend WithEvents Button9 As System.Windows.Forms.Button
  235. Friend WithEvents Button0 As System.Windows.Forms.Button
  236. Friend WithEvents Buttonc As System.Windows.Forms.Button
  237. Friend WithEvents Buttoncalc As System.Windows.Forms.Button
  238. Friend WithEvents Buttonplus As System.Windows.Forms.Button
  239. Friend WithEvents Buttonmin As System.Windows.Forms.Button
  240. Friend WithEvents Buttondelen As System.Windows.Forms.Button
  241. Friend WithEvents Buttonmaal As System.Windows.Forms.Button
  242.  
  243. End Class


---Form1.vb---
  1. Public Class Form1
  2. 'Variabelen setten'
  3. Dim waarde1 As Integer
  4. Dim waarde2 As Integer
  5. Dim oper As String
  6. Dim uitkomst2 As Integer
  7. 'De buttons'
  8. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  9. If Val(uitkomst.Text) = 0 Then
  10. uitkomst.Text = Button1.Text
  11. Else : uitkomst.Text &= Button1.Text
  12. End If
  13. End Sub
  14. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  15. If Val(uitkomst.Text) = 0 Then
  16. uitkomst.Text = Button2.Text
  17. Else : uitkomst.Text &= Button2.Text
  18. End If
  19. End Sub
  20. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  21. If Val(uitkomst.Text) = 0 Then
  22. uitkomst.Text = Button3.Text
  23. Else : uitkomst.Text &= Button3.Text
  24. End If
  25. End Sub
  26. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  27. If Val(uitkomst.Text) = 0 Then
  28. uitkomst.Text = Button4.Text
  29. Else : uitkomst.Text &= Button4.Text
  30. End If
  31. End Sub
  32. Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  33. If Val(uitkomst.Text) = 0 Then
  34. uitkomst.Text = Button5.Text
  35. Else : uitkomst.Text &= Button5.Text
  36. End If
  37. End Sub
  38. Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
  39. If Val(uitkomst.Text) = 0 Then
  40. uitkomst.Text = Button6.Text
  41. Else : uitkomst.Text &= Button6.Text
  42. End If
  43. End Sub
  44. Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
  45. If Val(uitkomst.Text) = 0 Then
  46. uitkomst.Text = Button7.Text
  47. Else : uitkomst.Text &= Button7.Text
  48. End If
  49. End Sub
  50. Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
  51. If Val(uitkomst.Text) = 0 Then
  52. uitkomst.Text = Button8.Text
  53. Else : uitkomst.Text &= Button8.Text
  54. End If
  55. End Sub
  56. Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
  57. If Val(uitkomst.Text) = 0 Then
  58. uitkomst.Text = Button9.Text
  59. Else : uitkomst.Text &= Button9.Text
  60. End If
  61. End Sub
  62. Private Sub Button0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button0.Click
  63. If Val(uitkomst.Text) = 0 Then
  64. uitkomst.Text = Button0.Text
  65. Else : uitkomst.Text &= Button0.Text
  66. End If
  67. End Sub
  68.  
  69. Private Sub Buttonplus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonplus.Click
  70. waarde1 = Val(uitkomst.Text)
  71. uitkomst.Text = "0"
  72. oper = "plus"
  73. End Sub
  74.  
  75. Private Sub Buttonmin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonmin.Click
  76. waarde1 = Val(uitkomst.Text)
  77. uitkomst.Text = "0"
  78. oper = "min"
  79. End Sub
  80.  
  81. Private Sub Buttondelen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttondelen.Click
  82. waarde1 = Val(uitkomst.Text)
  83. uitkomst.Text = "0"
  84. oper = "delen"
  85. End Sub
  86.  
  87. Private Sub Buttonmaal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonmaal.Click
  88. waarde1 = Val(uitkomst.Text)
  89. uitkomst.Text = "0"
  90. oper = "maal"
  91. End Sub
  92.  
  93. Private Sub Buttonc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonc.Click
  94. waarde1 = 0
  95. waarde2 = 0
  96. oper = ""
  97. uitkomst.Text = "0"
  98. End Sub
  99.  
  100. Private Sub Buttoncalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttoncalc.Click
  101. waarde2 = Val(uitkomst.Text)
  102. If oper = "plus" Then
  103. uitkomst2 = waarde1 + waarde2
  104. End If
  105. If oper = "min" Then
  106. uitkomst2 = waarde1 - waarde2
  107. End If
  108. If oper = "delen" Then
  109. uitkomst2 = waarde1 / waarde2
  110. End If
  111. If oper = "maal" Then
  112. uitkomst2 = waarde1 * waarde2
  113. End If
  114. uitkomst.Text = uitkomst2
  115. End Sub
  116.  
  117. Private Sub uitkomst_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles uitkomst.GotFocus
  118. Buttonc.Focus()
  119. End Sub
  120.  
  121. End Class
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Geen reacties (0)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.052s