home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l407 / 1.ddi / NUMBER.FR_ / NUMBER.bin (.txt)
Encoding:
Visual Basic Form  |  1993-04-28  |  2.8 KB  |  96 lines

  1. VERSION 2.00
  2. Begin Form frmNumber 
  3.    Caption         =   "Number System"
  4.    ClientHeight    =   3390
  5.    ClientLeft      =   2160
  6.    ClientTop       =   1950
  7.    ClientWidth     =   4515
  8.    Height          =   3795
  9.    Left            =   2100
  10.    LinkTopic       =   "Form5"
  11.    ScaleHeight     =   3390
  12.    ScaleWidth      =   4515
  13.    Top             =   1605
  14.    Width           =   4635
  15.    Begin CommandButton cmdClose 
  16.       Caption         =   "&Close"
  17.       Height          =   495
  18.       Left            =   2760
  19.       TabIndex        =   4
  20.       Top             =   1920
  21.       Width           =   1215
  22.    End
  23.    Begin OptionButton optHexButton 
  24.       Caption         =   "Use &hexadecimal"
  25.       Height          =   495
  26.       Left            =   600
  27.       TabIndex        =   3
  28.       Top             =   2520
  29.       Width           =   1815
  30.    End
  31.    Begin OptionButton optDecButton 
  32.       Caption         =   "Use &decimal"
  33.       Height          =   495
  34.       Left            =   600
  35.       TabIndex        =   2
  36.       Top             =   1920
  37.       Value           =   -1  'True
  38.       Width           =   1815
  39.    End
  40.    Begin OptionButton optOctButton 
  41.       Caption         =   "Use &octal"
  42.       Height          =   495
  43.       Left            =   600
  44.       TabIndex        =   1
  45.       Top             =   1320
  46.       Width           =   1815
  47.    End
  48.    Begin TextBox txtNumber 
  49.       Height          =   375
  50.       Left            =   600
  51.       TabIndex        =   0
  52.       Top             =   600
  53.       Width           =   3375
  54.    End
  55.    Begin Label Label1 
  56.       Caption         =   "Enter a number:"
  57.       Height          =   255
  58.       Left            =   600
  59.       TabIndex        =   5
  60.       Top             =   240
  61.       Width           =   2175
  62.    End
  63. Option Explicit
  64. Dim CurrentNum As Variant
  65. Sub cmdClose_Click ()
  66.    Unload Me    ' Unload this form.
  67. End Sub
  68. Sub optDecButton_Click ()
  69.     txtNumber.Text = Format(CurrentNum)
  70. End Sub
  71. Sub optHexButton_Click ()
  72.     txtNumber.Text = Hex(CurrentNum)
  73. End Sub
  74. Sub optOctButton_Click ()
  75.     txtNumber.Text = Oct(CurrentNum)
  76. End Sub
  77. Sub txtNumber_Change ()
  78. ' Val function interprets numbers beginning with &O as octal;
  79. ' numbers beginning with &H as hexidecimal.
  80.     If optOctButton.Value = True Then
  81.         CurrentNum = Val("&O" & LTrim(txtNumber.Text) & "&")
  82.     ElseIf optDecButton.Value = True Then
  83.         CurrentNum = Val(LTrim(txtNumber.Text) & "&")
  84.     Else
  85.         CurrentNum = Val("&H" & LTrim(txtNumber.Text) & "&")
  86.     End If
  87. End Sub
  88. Sub txtNumber_KeyPress (KeyAscii As Integer)
  89.      ' This code prevents the user from entering
  90.      ' a negative number, or a decimal point.
  91.      If KeyAscii < 48 Or KeyAscii > 57 Then
  92.         KeyAscii = 0
  93.         Beep
  94.      End If
  95. End Sub
  96.