Note: If your Hint is more than a paragraph long, please put it on a separate page.
If you are creating a new page use the following naming convention
eg 2009 S1 Smith Mary HH 1(if you studied in 2009 semester 1 and your name is Mary Smith, Handy Hing 1)
Aust, Luke The following code works as a random number generator.
CStr(Int(Rnd() * X))
Replace X with the largest number you wish possible.
Bertke, Steven
1) using .Chars
I will use a bit of code from the last project as an example.
If temp.ToUpper.Chars(0) = "A" Then
lstA.Items.Add(temp)
ElseIf temp.ToUpper.Chars(0) = "B" Then
lstB.Items.Add(temp)
End If
temp is a variable with a string in it
Basically this code converts the string to upper then .Chars(0) checks the first character of the string
If you put this in a for loop, you could replace 0 with i and it would check every character in the string.
However for this particular scenario I only needed to check the first letter, hence 0.
2)Adding tooltips to your forms
On the design page in the toolbox under common controls you will find the tool tip feature, Click it and then click on your form.
Enter the following code on form load
ToolTip1.SetToolTip(btntest, "test")
tooltip1 being the name of the tooltip
settooltip is self explanatory
btntest is the name of your button
and "test" is what you want the tooltip to display
Alter the tooltip delay times in the properties tab
Brookshaw, Martin
De San Miguel, Dean
Greck, Cameron
Greig, Deveson
Griffiths, Paul If you add a string variable a the beginning of the form like this.
Public Class frmMain
Dim msg As String = "Hello User"
Dim handyHint1 As Integer = 46
Private Sub btnEx1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEx1.Click
MessageBox.Show(msg, "First", MessageBoxButtons.OK, MessageBoxIcon.Information)
MessageBox.Show(handyHint1, "Second", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub btnEx2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEx2.Click
MessageBox.Show(msg, "First", MessageBoxButtons.OK, MessageBoxIcon.Information)
MessageBox.Show(handyHint1, "Second", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
End Class
Both of the message boxes in both buttons will answer the same thing and when you change the variable then the new one will go on over the whole form.
Hill, Brett
Handy Hint 1
You may already be familiar with the mid() function which allows you to find characters in a string.
there is another function called Mid which allows you to replace characters in a string, it is written in format:
Mid(STRING,INDEX,LEGTH) = OTHER STRING
where STRING is your original string, INDEX is where your replacement starts and Length is how many charaters across the replacement will persist.
so DIM STR as String = "Hello Joe" Mid(STR, 7, 3) = "Bob"
will change the string from "Hello Joe" to "Hello Bob".
The limitation on this function is that since a String acts as an array of characters if your replacement extends beyond the length of the original string, the additional characters will be lost. For example if you were to replace "Bob" in the previous example with "Everyone" only the first three characters would place themselves in the string, even if you set the replacement length to over three characters you will still end up with "Hello Eve". Note: a work around is possible using for loops, a varable for persistance length and appending blank characters
Handy Hint 2
if you need to re-use multiple sections of code, and continually going ctrl+c/ctrl+v doesn't appeal to you highlight and drag the section(s) of code into your toolbox. The toolbox will hold the code section like a clipboard where you can then drag the same section of code onto the page multiple times.
Hopkin, Janice Hint1
If you have files stored in your bin folder click the All Files box in the solution explorer so you can easily view and access them Hint2
This small piece of code uses the System.Net.Dns Class to find out the IP address of the computer that you are on. It uses the methods GetHostName and GetHostEntry then displays the results in a message box.
Dim strHostName As String
Dim strIPAddress As String
strHostName = System.Net.Dns.GetHostName()
strIPAddress = System.Net.Dns.GetHostEntry(strHostName).AddressList(0).ToString()
MessageBox.Show("Host Name: " & strHostName & "; IP Address: " & strIPAddress, "Your IP Address", MessageBoxButtons.OKCancel, MessageBoxIcon.Information)
Hubbard, Lisa
Leam, Callon
Leavesley, Tristan
Mazzarol, Anthony
McAllister, Michael If you are unsure on the syntax of a particular function (e.g a For Loop, Do While) however, F8 help is not available (or cryptic) press tab twice after writing the first line of the function you would like to do.
i.e. If you forget on how to do a do while loop type in do while and press tab twice.
Do
While True
End While
It should give you the basic outline of the syntax of the code, try it with a IF statement aswell.(type If then press tab twice)
If True Then
End If
Use this code to fade in (or fade out if you change the step to a negative) a form
For Clear = 0 to 1.01 step 0.0001 Me.Opacity = Clear
Next
Mess with the Step to your liking, this code doesn't really work on the form Load Event on your main form, so its best suited for opening a second form and fading out the other form and fading in the new form.
Morrison, Raymond
Handy Hint number one!
i personally had difficulty translating a String into a Integer for a textbox format so i found an easy way to do it! Just change into a Currency form.
For example
TxtCartotal.Text = FormatCurrency(GST + SubTotal)
Handy Hint Number Two!
You can actually Create a Basic aNimation with buttons and a Timer
just set the timer to start when you click the button and another timer to stop for example all you need is to have a picture box in each corner and it will move from each to each here is the code you need just change it to different numbers
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
enemy.Left += 2
If enemy.Left = PictureBox3.Left Then '
Timer2.Enabled = False
Timer3.Enabled = True
End If
Radice, Michael
In textbox only allow for the entry of Numbers
Private Sub txtUnknown.KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtUnknown.KeyPress
If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then
e.Handled = True
End If
If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then
e.Handled = False
End If
End Sub
In textbox only allow for the entry of Letters
Private Sub txtUnknown_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtUnknown.KeyPress
If e.KeyChar <> ChrW(Keys.Back) Then
If (e.KeyChar.ToString >= "A" And e.KeyChar.ToString <= "Z") Or (e.KeyChar.ToString >= "a" And e.KeyChar.ToString <= "z") Then
Else
e.Handled = True
End If
End If
End Sub Scott, Justin
Handy Hints Semester 1, 2010
Note: If your Hint is more than a paragraph long, please put it on a separate page.
If you are creating a new page use the following naming conventioneg 2009 S1 Smith Mary HH 1(if you studied in 2009 semester 1 and your name is Mary Smith, Handy Hing 1)
Aust, LukeThe following code works as a random number generator.
CStr(Int(Rnd() * X))
Replace X with the largest number you wish possible.
Bertke, Steven
1) using .Chars
I will use a bit of code from the last project as an example.
If temp.ToUpper.Chars(0) = "A" Then
lstA.Items.Add(temp)
ElseIf temp.ToUpper.Chars(0) = "B" Then
lstB.Items.Add(temp)
End If
temp is a variable with a string in it
Basically this code converts the string to upper then .Chars(0) checks the first character of the string
If you put this in a for loop, you could replace 0 with i and it would check every character in the string.
However for this particular scenario I only needed to check the first letter, hence 0.
2) Adding tooltips to your forms
On the design page in the toolbox under common controls you will find the tool tip feature, Click it and then click on your form.
Enter the following code on form load
ToolTip1.SetToolTip(btntest, "test")
tooltip1 being the name of the tooltip
settooltip is self explanatory
btntest is the name of your button
and "test" is what you want the tooltip to display
Alter the tooltip delay times in the properties tab
Brookshaw, Martin
De San Miguel, Dean
Greck, Cameron
Greig, Deveson
Griffiths, Paul
If you add a string variable a the beginning of the form like this.
Public Class frmMain
Dim msg As String = "Hello User"
Dim handyHint1 As Integer = 46
Private Sub btnEx1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEx1.Click
MessageBox.Show(msg, "First", MessageBoxButtons.OK, MessageBoxIcon.Information)
MessageBox.Show(handyHint1, "Second", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub btnEx2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEx2.Click
MessageBox.Show(msg, "First", MessageBoxButtons.OK, MessageBoxIcon.Information)
MessageBox.Show(handyHint1, "Second", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
End Class
Both of the message boxes in both buttons will answer the same thing and when you change the variable then the new one will go on over the whole form.
Hill, Brett
Handy Hint 1
You may already be familiar with the mid() function which allows you to find characters in a string.there is another function called Mid which allows you to replace characters in a string, it is written in format:
Mid(STRING,INDEX,LEGTH) = OTHER STRING
where STRING is your original string, INDEX is where your replacement starts and Length is how many charaters across the replacement will persist.
so
DIM STR as String = "Hello Joe"
Mid(STR, 7, 3) = "Bob"
will change the string from "Hello Joe" to "Hello Bob".
The limitation on this function is that since a String acts as an array of characters if your replacement extends beyond the length of the original string, the additional characters will be lost. For example if you were to replace "Bob" in the previous example with "Everyone" only the first three characters would place themselves in the string, even if you set the replacement length to over three characters you will still end up with "Hello Eve".
Note: a work around is possible using for loops, a varable for persistance length and appending blank characters
Handy Hint 2
if you need to re-use multiple sections of code, and continually going ctrl+c/ctrl+v doesn't appeal to you highlight and drag the section(s) of code into your toolbox. The toolbox will hold the code section like a clipboard where you can then drag the same section of code onto the page multiple times.Hopkin, Janice
Hint1
If you have files stored in your bin folder click the All Files box in the solution explorer so you can easily view and access them
Hint2
This small piece of code uses the System.Net.Dns Class to find out the IP address of the computer that you are on. It uses the methods GetHostName and GetHostEntry then displays the results in a message box.
Dim strHostName As String
Dim strIPAddress As String
strHostName = System.Net.Dns.GetHostName()
strIPAddress = System.Net.Dns.GetHostEntry(strHostName).AddressList(0).ToString()
MessageBox.Show("Host Name: " & strHostName & "; IP Address: " & strIPAddress, "Your IP Address", MessageBoxButtons.OKCancel, MessageBoxIcon.Information)
Hubbard, Lisa
Leam, Callon
Leavesley, Tristan
Mazzarol, Anthony
McAllister, Michael
If you are unsure on the syntax of a particular function (e.g a For Loop, Do While) however, F8 help is not available (or cryptic) press tab twice after writing the first line of the function you would like to do.
i.e. If you forget on how to do a do while loop type in do while and press tab twice.
Do
While True
End While
It should give you the basic outline of the syntax of the code, try it with a IF statement aswell. (type If then press tab twice)
If True Then
End If
Use this code to fade in (or fade out if you change the step to a negative) a form
For Clear = 0 to 1.01 step 0.0001 Me.Opacity = Clear
Next
Mess with the Step to your liking, this code doesn't really work on the form Load Event on your main form, so its best suited for opening a second form and fading out the other form and fading in the new form.
Morrison, Raymond
Handy Hint number one!
i personally had difficulty translating a String into a Integer for a textbox format so i found an easy way to do it! Just change into a Currency form.For example
TxtCartotal.Text = FormatCurrency(GST + SubTotal)
Handy Hint Number Two!
You can actually Create a Basic aNimation with buttons and a Timerjust set the timer to start when you click the button and another timer to stop for example all you need is to have a picture box in each corner and it will move from each to each here is the code you need just change it to different numbers
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
enemy.Left += 2
If enemy.Left = PictureBox3.Left Then '
Timer2.Enabled = False
Timer3.Enabled = True
End If
Radice, Michael
In textbox only allow for the entry of Numbers
Private Sub txtUnknown.KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtUnknown.KeyPressIf (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then
e.Handled = True
End If
If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then
e.Handled = False
End If
End Sub
In textbox only allow for the entry of Letters
Private Sub txtUnknown_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtUnknown.KeyPressIf e.KeyChar <> ChrW(Keys.Back) Then
If (e.KeyChar.ToString >= "A" And e.KeyChar.ToString <= "Z") Or (e.KeyChar.ToString >= "a" And e.KeyChar.ToString <= "z") Then
Else
e.Handled = True
End If
End If
End Sub
Scott, Justin
Stephen, Thomas