Visual Basic 2005 - GUI Summary v2

Controls: Label, Textbox, Button, PictureBox, RadioButton, CheckBox, ListBox.

Containers: GroupBox.

Label - For fixed text.
lbl.Text = s Sets text to s.
Textbox - Box containing one line of text.
s = tb.Text Returns string in text box.
tb.Text = s Sets text to s.
tb.Focus() Sets focus to this text box.
tb.SelectAll() Selects the text.
tb.Clear() Puts empty string in text box.
Button
btn.Enabled = True / False True enables, False disables button.
ListBox (p. 526) (Properties: SelectedItem, SelectedIndex, SelectionMode, Sorted)
Me.lstbx.Items.Add(s) Adds string s to ListBox lstbx. Also Items.Insert(i, s), Items.Remove(s), Items.RemoveAt(i), Items.Clear().
RadioButton or CheckBox
rbcb.Checked True if the radio button or check box is checked.
InputBox - Input dialog
s = InputBox(msg) Displays input dialog prompting with msg. Returns "" if cancelled.
s = InputBox(msgt) As above with title t in titlebar.
s = InputBox(msgtdflt) As above but initializes textbox to dflt.
MessageBox - Output dialog
MessageBox.Show(msg) Displays dialog box with msg.
MessageBox.Show(txt, cap,
btns, icon [, dfltBtn])
Displays dialog box with many options. See p 341.
Many MessageBox constants... There are many useful button and icon constants. See p 341.

Events - Click, KeyPress

KeyPress - System.Windows.Forms.KeyPressEventArgs e
e.Handled = True/False True means it will be ignored by others.
s = e.KeyChar Key that was pressed.

Other

ControlChar.Back


Public Domain 2007 Fred Swartz