VB.NETThis is a featured page

TextBox Example

Code:
Dim TextBox1 As New TextBox()
TextBox1.Text = "Hello World"
'Sets the text of the textbox to "Hello World"
TextBox1.AcceptsReturn = True
'This will allow the user to press Return in the textbox and it will make a new line
TextBox1.AcceptsTab = True
'This will allow the user to press Tab in the textbox and it will place a tab in the textbox
TextBox1.AppendText(vbCrLf & "Hello World AGAIN!")
'This will Append "Hello World AGAIN!" on a new line in the text box
TextBox1.AutoSize = False
'Setting this false will alow you to set the height of the textbox, wether its multiline or not..
TextBox1.BackColor = Color.Blue
'Makes the background color Blue
TextBox1.ForeColor = Color.Black
'Makes the text black
TextBox1.BackgroundImage = Image.FromFile("C:\MyTextBoxBackground.gif")
'Sets the textbox's background to the path provided
TextBox1.BorderStyle = BorderStyle.FixedSingle
'Insted of the default 3d border this will make it a cool slim line border
TextBox1.Clear()
'Clears the text in the textbox
TextBox1.Cursor = Cursors.Hand
'When the user moves thier mouse over the control it will set the cursor to the "hand" cursor
TextBox1.Enabled = False
'Makes the textbox a grayish color and does not allow input or delete or selection
TextBox1.Font = New Drawing.Font("Comic Sans MS", 12, FontStyle.Bold, GraphicsUnit.Pixel)
'Sets the font of the textbox to Comic Sans MS, 12 pixels, and bold
TextBox1.MaxLength = 3000
'Sets the maximum chars that can be put in the textbox
TextBox1.ReadOnly = True
'allows the user to select but not change
TextBox1.ResetText()
'Resets the text back to default
TextBox1.ScrollBars = ScrollBars.Vertical
'Makes scrollbars on the right side only
TextBox1.ScrollToCaret()
'This will scroll the textbox to where the Caret is (the blinking text thing)
TextBox1.Select(0, 11)
'This will select the text from the begining to the end of "Hello World"
TextBox1.SelectAll()
'This will select all text in the textbox
Dim SelectedText As String = TextBox1.SelectedText
'This will set the Var SelectedText to the text selected in the textbox
TextBox1.SelectionStart = 0
'This will start a selection at the begining of the textbox
TextBox1.SelectionLength = 11
'This (used with SelectionStart) will select the "Hello World" in our textbox (same as Select(0, 11))
TextBox1.Size = New Size(300, 400)
'Sets the size of the textbox to 300x400
TextBox1.TabStop = False
'by setting this false when the user "tabs" through your controls it will not stop at this textbox
TextBox1.TextAlign = HorizontalAlignment.Center
'Aligns the text "Center"
Dim i As Integer = TextBox1.TextLength
'Sets i to the Lenght of the TextBox (total chars)
TextBox1.Undo()
'Undo's the last edit operation done to the textbox
TextBox1.Visible = True
'Wether its visible or not (false the user will NOT see the textbox)
TextBox1.WordWrap = False
'Wether it "Wrap"s the text in the textbox or not

'A couple of examples....

TextBox1.Text = "Hello World"
TextBox1.SelectAll()
TextBox1.Copy()
'The above will select all the text in the textbox and copy it to the clipboard

TextBox1.SelectAll()
TextBox1.Cut()
'The above will select all the text and Cut it into the clipboard

TextBox1.SelectionStart = TextBox1.TextLength - 1
TextBox1.SelectionLength = 1
'The above will select the last charicter in the text box (in this case "d")

ComboBox Example

Code:
ComboBox1.BackColor = Color.Blue
ComboBox1.Cursor = Cursors.Hand
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
'This will set the combobox so that the user cant type in a value
ComboBox1.DropDownWidth = 200
'Sets the width of the dropdown list
ComboBox1.DroppedDown = True
'setting this will drop the menu down.
ComboBox1.Enabled = True
ComboBox1.Font = New Drawing.Font("Comic Sans MS", FontStyle.Bold)
ComboBox1.ForeColor = Color.Black
ComboBox1.MaxDropDownItems = 5
'sets the max items that are displayed when the combobox is "DropedDown"
Dim i As Integer = ComboBox1.SelectedIndex
'sets "i" to the Combobox's selected index

'Examples...

Private Sub ComboBox1_SelectedIndexChanged(ByVal Sender As Object, ByVal e As EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim i As Integer = ComboBox1.SelectedIndex
Dim s As String = ComboBox1.SelectedItem
MsgBox("You selected index " & i & ", " & s, MsgBoxStyle.OKOnly)
End Sub

Button Example

Code:
Button1.BackColor = Color.Blue
Button1.Cursor = Cursors.Hand
Button1.Enabled = True
Button1.FlatStyle = FlatStyle.Flat
'This is cool, FlatStyle.Flat makes the button flat it has a mouseover effect and everything...
Button1.Font = New Font("Comic Sans MS", FontStyle.Bold)
Button1.ForeColor = Color.White
Button1.Height = 20
Button1.Image = Image.FromFile("C:\MyImage.jpg")
'set the button image
Button1.ImageAlign = ContentAlignment.BottomRight
'set the button align to bottom right
Button1.Location = New Point(0, 0)
'puts the button in the top left corner (0, 0)
Button1.PerformClick()
'this is handy, by calling this you simulate a click on the button
Button1.Size = New Size(300, 300)
Button1.Text = "Click Me"
Button1.TextAlign = ContentAlignment.MiddleLeft
Button1.Visible = True
Button1.Width = 20

'Examples

Private Sub Button1_Click(ByVal Sender As Object, ByVal e As EventArgs) Handles Button1.Click
MsgBox("You clicked this button")
End Sub


No user avatar
VICTOR_KATTA
Latest page update: made by VICTOR_KATTA , Nov 2 2006, 7:47 AM EST (about this update About This Update VICTOR_KATTA aaa - VICTOR_KATTA

764 words added

view changes

- complete history)
Keyword tags: None
More Info: links to this page

Anonymous  (Get credit for your thread)


There are no threads for this page.  Be the first to start a new thread.