VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "数制转换"
   ClientHeight    =   2580
   ClientLeft      =   1095
   ClientTop       =   1515
   ClientWidth     =   3915
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   12
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2580
   ScaleWidth      =   3915
   Begin VB.CommandButton Command1 
      Caption         =   "转换"
      Height          =   495
      Left            =   360
      TabIndex        =   6
      Top             =   2040
      Width           =   1095
   End
   Begin VB.TextBox Text3 
      Height          =   420
      Left            =   2040
      TabIndex        =   4
      Text            =   "　"
      Top             =   1440
      Width           =   1815
   End
   Begin VB.TextBox Text2 
      Height          =   420
      Left            =   1920
      TabIndex        =   3
      Text            =   "　"
      Top             =   720
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   420
      Left            =   1920
      TabIndex        =   2
      Text            =   "　"
      Top             =   120
      Width           =   1815
   End
   Begin VB.Label Label3 
      Caption         =   "转换成R进制数"
      Height          =   495
      Left            =   240
      TabIndex        =   5
      Top             =   1560
      Width           =   2535
   End
   Begin VB.Label Label2 
      Caption         =   "输入R进制 ：（2  -16）  "
      Height          =   615
      Left            =   360
      TabIndex        =   1
      Top             =   720
      Width           =   1455
   End
   Begin VB.Label Label1 
      Caption         =   "输入十进制数："
      Height          =   375
      Left            =   360
      TabIndex        =   0
      Top             =   240
      Width           =   1695
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
 Function TranDec$(ByVal m%, ByVal r%)
    Dim StrDtoR$
    Dim iB%, mr%
    StrDtoR = ""
    Do While m <> 0
       mr = m Mod r
       m = m \ r
       If mr >= 10 Then
         StrDtoR = Chr(mr - 10 + 65) & StrDtoR        '余数>=10 转换为A～F,最先求出的余数位数最低
       Else
         StrDtoR = mr & StrDtoR      '余数<10 直接连接，最先求出的余数位数最低
       End If
    Loop
    TranDec = StrDtoR
End Function

Private Sub Command1_click()
    Dim m0%, r0%, i%
    m0 = Val(Text1.Text)
    r0 = Val(Text2.Text)
    If r0 < 2 Or r0 > 16 Then
      i = MsgBox("输入的R进制数超出范围", vbRetryCancel)
      If i = vbRetry Then
        Text2.Text = ""
        Text2.SetFocus
      Else
        End
      End If
     End If
    Label3.Caption = "转换成" & r0 & "进制数"
    Text3.Text = TranDec(m0, r0)
End Sub


