home *** CD-ROM | disk | FTP | other *** search
- Type OptionButtonMasterForm From SampleMasterForm
- Dim Label1 As New Label
- Dim txtValueBox As New TextBox
- Dim optOctal As New OptionButton
- Dim optDecimal As New OptionButton
- Dim optHex As New OptionButton
- Dim FontValueBox As New Font
- Dim CurrentNumber As String
-
- ' METHODS for object: OptionButtonMasterForm
- Sub optDecimal_Click()
- If txtValueBox.Text <> "" Then
- txtValueBox.Text = CurrentNumber
- End If
- End Sub
-
- Sub optHex_Click()
- If txtValueBox.Text <> "" Then
- txtValueBox.Text = Hex(CurrentNumber)
- End If
- End Sub
-
- Sub optOctal_Click()
- If txtValueBox.Text <> "" Then
- txtValueBox.Text = Oct(CurrentNumber)
- End If
- End Sub
-
- Sub ResetApplication_Click ()
- ' If the form is not loaded yet, then get it loaded and pop out of here.
- If hWnd = 0 Then
- LoadForm
- Exit Sub
- End If
-
- ' Setup the option buttons
- optOctal.Value = False
- optDecimal.Value = True
- optHex.Value = False
-
- txtValueBox.Text = ""
- txtValueBox.SetFocus
- End Sub
-
- Sub txtValueBox_Change()
- If txtValueBox.Text <> "" Then
- ' Val function interprets numbers beginning with &O as octal;
- ' numbers beginning with &H as hexidecimal.
- If optOctal.Value = True Then
- CurrentNumber = Val("&O" & LTrim(txtValueBox.Text) & "&")
- ElseIf optHex.Value = True Then
- CurrentNumber = Val("&H" & LTrim(txtValueBox.Text) & "&")
- Else
- CurrentNumber = Val(LTrim(txtValueBox.Text) & "&")
- End If
- Else
- CurrentNumber = ""
- End If
- End Sub
-
- Sub txtValueBox_KeyPress(KeyAscii As Integer)
- ' This code prevents the user from entering characters that are
- ' invalid for given radix (also no negatives or floating decimal points).
- Dim maxDigit, isDigit, isHexDig As Long
-
- ' Allow backspace straight through...
- If KeyAscii = 8 Then Exit Sub
-
- ' Restrict digits to 0-7 if chosen radix is octal...
- If optOctal.Value Then maxDigit = Asc("7") Else maxDigit = Asc("9")
- isDigit = KeyAscii >= Asc("0") && KeyAscii <= maxDigit
-
- ' Only do extra checking if key pressed isn't a valid digit...
- If Not isDigit Then
- If optHex.Value = 0 Then
- KeyAscii = 0
- Else
- isHexDig = KeyAscii >= Asc("a") && KeyAscii <= Asc("f")
- isHexDig = isHexDig || (KeyAscii >= Asc("A") && KeyAscii <= Asc("F"))
- If Not isHexDig Then KeyAscii = 0
- End If
- End If
-
- End Sub
-
- End Type
-
- Begin Code
- ' Reconstruction commands for object: OptionButtonMasterForm
- '
- With OptionButtonMasterForm
- .Caption := "OptionButton Demonstration"
- .Move(3180, 2130, 6420, 4200)
- .SampleDir := "C:\ENVELOP\bootcamp\basic\opbutton\"
- .SampleName := "OPBUTTON"
- .CurrentNumber := ""
- With .Label1
- .Caption := "1. Please enter a number."
- .ForeColor := 13107200
- .ZOrder := 1
- .Move(300, 300, 2850, 300)
- End With 'OptionButtonMasterForm.Label1
- With .txtValueBox
- .Font := OptionButtonMasterForm.FontValueBox
- .ZOrder := 2
- .Move(600, 750, 4950, 600)
- End With 'OptionButtonMasterForm.txtValueBox
- With .optOctal
- .Caption := " Use &Octal number."
- .ZOrder := 3
- .Move(1200, 1800, 3450, 300)
- .TabGroup := True
- End With 'OptionButtonMasterForm.optOctal
- With .optDecimal
- .Caption := " Use &Decimal number."
- .ZOrder := 4
- .Move(1200, 2250, 3450, 300)
- .TabStop := True
- .Value := True
- End With 'OptionButtonMasterForm.optDecimal
- With .optHex
- .Caption := " Use He&xadecimal number."
- .ZOrder := 5
- .Move(1200, 2700, 4200, 300)
- End With 'OptionButtonMasterForm.optHex
- With .FontValueBox
- .FaceName := "Arial"
- .Size := 24.000000
- .Bold := True
- .Italic := False
- .Strikethru := False
- End With 'OptionButtonMasterForm.FontValueBox
- With .helpfile
- .FileName := "C:\ENVELOP\bootcamp\basic\opbutton\OPBUTTON.hlp"
- End With 'OptionButtonMasterForm.helpfile
- End With 'OptionButtonMasterForm
- End Code
-