30.01.2015 Views

the integration of visual basic programming language into physics ...

the integration of visual basic programming language into physics ...

the integration of visual basic programming language into physics ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 5. Displaying error message<br />

If TextBox1.Text = Nothing Then<br />

MsgBox("Please type in a value for δmin!", MsgBoxStyle.Exclamation, "Error")<br />

ElseIf TextBox1.Text < 30 Or TextBox1.Text > 50 Then MsgBox("δmin cannot be above 50<br />

or below 30 degrees!", MsgBoxStyle.Exclamation, "Error")<br />

ElseTextBox2.Text = (TextBox1.Text + 60) / 2<br />

TextBox3.Text = 0.01745 * ((TextBox1.Text + 60) / 2)<br />

TextBox4.Text = Math.Sin(0.01745 * ((TextBox1.Text + 60) / 2))<br />

TextBox5.Text = "0.5235"<br />

TextBox6.Text = "0.5000"<br />

TextBox7.Text = (Math.Sin(0.01745 * ((TextBox1.Text + 60) / 2))) / 0.5<br />

End If<br />

All <strong>the</strong>se lines are for calculating <strong>the</strong> values, for <strong>the</strong> first button. The reset button will have no<br />

errors to check and will be easier to write. All it does is wiping <strong>the</strong> data written in <strong>the</strong> text boxes.<br />

Double click on <strong>the</strong> “Reset” button. It will take you to <strong>the</strong> coding page.<br />

We write <strong>the</strong> reset code between “Private Sub Button2_Click(ByVal sender As System.Object,<br />

ByVal e As System.EventArgs) Handles Button2.Click” and <strong>the</strong> line below it (which is where <strong>the</strong> code<br />

for this button ends) “End Sub”<br />

The code is like this:<br />

TextBox1.Text = Nothing<br />

TextBox2.Text = Nothing<br />

TextBox3.Text = Nothing<br />

TextBox4.Text = Nothing<br />

TextBox5.Text = Nothing<br />

TextBox6.Text = Nothing<br />

TextBox7.Text = Nothing<br />

Like we said all it does is wiping <strong>the</strong> values in <strong>the</strong> Text Boxes. After typing in those lines <strong>the</strong><br />

code for <strong>the</strong> Reset button should be like this [12]:<br />

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)<br />

Handles Button2.Click<br />

TextBox1.Text = Nothing<br />

TextBox2.Text = Nothing

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!