一个程序实现如下功能:在文本框text1中输入一个数,在文本框text2中输入需要转换的进制(小于等于16),点击转换按钮,在标签Label3输出转换后的十进制数,程序运行界面如下图所示:
请在划线处填入合适的代码
Private Sub Command1_Click()
Dim s As String, k As Integer
{#blank#}1{#/blank#}
k = Val(Text2.Text)
Label3.Caption=“对应的十进制数:”+Str(toD(s, k))
End Sub
Function toD(s As String, k As Integer) As Integer
Dim ans As Integer, x As Integer
ans = 0
For i = 1 To Len(s)
If Mid(s, i, 1) >= "A" And Mid(s, i, 1) <= "F" Then
x = Asc(Mid(s, i, 1))- Asc(“A”)十 10
Else
x = Val(Mid(s, i, 1))
End If
{#blank#}2{#/blank#}
Next i
{#blank#}3{#/blank#}
End Function