Handy Hints Semester 1, 2011 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 Hint 1)
Dim img1 As New Bitmap(“filename”) Dim img2 As New Bitmap(“filename”) Dim newImage As New Bitmap(img1.Width + img2.Width, Math.Max(img1.Height, img2.Height)) Dim gr As Graphics = Graphics.FromImage(newImage)
gr.DrawImage(img1, Point.Empty) gr.DrawImage(img2, New Point(img1.Width, 0))
Hint 2-
Removing items form a Listbox -
If ListBox1.SelectedIndicies.Count <> 0 Then For i = ListBox1.SelectedIndicies.Count – 1 To 0 Step -1 ListBox1.Items.RemoveAt(ListBox1.SelectedIndicies(i)) Next End If
Leomaro Andrew
Continuation Characters:
In visual studios 2010 you no longer have to use the underscore to continue the code onto the nect line. In visual studios 2010 you can now continue the code onto the
Opperman Jacob:
{ With Function in VB
The “with” function in VB can make programming faster, with the idea of tipping something ones and it getting added on to the front every time.
This helps particular when u change properties of an object.
Or have to do multiple coding on one particular object.
With MyLabel .Height = 2000 .Width = 2000 .Caption = "This is MyLabel" .visible = True End With
Auto Populate Months Populating a combo or list box with the months of the year isn’t difficult. You can type the literal names as the control’s row source or use the MonthName() function in a simple VBA For loop. Normal Example (long code)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim i As Integer
For i = 1 To 12 ComboBox1.Items.Add (MonthName(i)) Next End Sub End Class
}
Ruchotzke Tyler
Simpson Maxwell
Van Der Westhuyzen Pieter:
{ Randomize:
dim int as integer
int = randomize.next(1, 100) randomize.next is giving int the value of a random number, the two numbers
in the brackets is giving it a minium and maximum random value
GoTo:
GoTo Line1
me.visible = true
Line1:
//this code skips all code and goes straight to the line you tell it to
}
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 Hint 1)
Ashworth Brandon
http://rockyvb.wikispaces.com/2011+S1+Brandon+AshworthBoorman Joel
Booth Dylan
http://rockyvb.wikispaces.com/Dylan+BoothHarris Damon
Hawkins Matthew
Jarvis Tristan:
Hint 1-
Creates one image out of two -
Dim img1 As New Bitmap(“filename”)
Dim img2 As New Bitmap(“filename”)
Dim newImage As New Bitmap(img1.Width + img2.Width, Math.Max(img1.Height, img2.Height))
Dim gr As Graphics = Graphics.FromImage(newImage)
gr.DrawImage(img1, Point.Empty)
gr.DrawImage(img2, New Point(img1.Width, 0))
Hint 2-
Removing items form a Listbox -
If ListBox1.SelectedIndicies.Count <> 0 Then
For i = ListBox1.SelectedIndicies.Count – 1 To 0 Step -1
ListBox1.Items.RemoveAt(ListBox1.SelectedIndicies(i))
Next
End If
Leomaro Andrew
Continuation Characters:In visual studios 2010 you no longer have to use the underscore to continue the code onto the nect line. In visual studios 2010 you can now continue the code onto the
Opperman Jacob:
{With Function in VB
The “with” function in VB can make programming faster, with the idea of tipping something ones and it getting added on to the front every time.
This helps particular when u change properties of an object.
Or have to do multiple coding on one particular object.
Object
Label name: MyLabel
Example of normal code:
MyLabel.Height = 200
MyLabel.Width = 2000
MyLabel.Caption = "This is MyLabel"
MyLabel.visible = True
Example with the, `With’function:
With MyLabel
.Height = 2000
.Width = 2000
.Caption = "This is MyLabel"
.visible = True
End With
Auto Populate Months
Populating a combo or list box with the months of the year isn’t difficult. You can type the literal names as the control’s row source or use the MonthName() function in a simple VBA For loop.
Normal Example (long code)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add (“January”)
ComboBox1.Items.Add (“Feb..”)
ComboBox1.Items.Add (“March…”)
End Sub
End Class
Example Fast way:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 1 To 12
ComboBox1.Items.Add (MonthName(i))
Next
End Sub
End Class
}
Ruchotzke Tyler
Simpson Maxwell
Van Der Westhuyzen Pieter:
{ Randomize:dim int as integer
int = randomize.next(1, 100)
randomize.next is giving int the value of a random number, the two numbers
in the brackets is giving it a minium and maximum random value
GoTo:
GoTo Line1
me.visible = true
Line1:
//this code skips all code and goes straight to the line you tell it to
}