Function myDecimal(ByVal s$, ByVal r%) As Integer
Dim i%, c$, n%
For i = 1 To Len(s)
c = Mid(s, i, 1)
Select Case c
Case "a" To "z"
n = Asc(c) - Asc("a") + 10
Case "A" To "Z"
n = Asc(c) - Asc("A") + 10
Case Else
n = Val(c)
End Select
myDecimal = _________
Next
End Function
举一反三
- 下列Encode函数的功能是对字符串s里的数字字符进行加密,加密方法是增加序数n(数字字符加n后还是在数字字符范围内),如n=3,"Text123789"-->"Text456012"。 请在_________处填入适当的内容完善程序。 Function Encode(ByVal s$, ByVal n) As String Dim i%, c$, cvalue% For i = 1 To Len(s) c = Mid(s, i, 1) Select Case c Case "0" To "9" cvalue = Val(c) + n If cvalue > 9 Then _________ c = CStr(cvalue) ' CStr()函数将数值转换成数字字符 End Select Encode = Encode & c Next End Function
- 以下程序段中,执行结果与其他3个选项不同的是 A: Dim y As Integer B: y = 11 C: Select Case y D: Case 15 To 5 E: Print "Executed" F: End Select G: Dim y As Integer H: y = 10 I: Select Case y J: Case Is > 10, Is < 10 K: Print " Executed " L: End Select M: Dim y As Integer N: y = 10 O: Select Case y P: Case Is > 15, 1, 5 To 8 Q: Print " Executed " R: End Select S: Dim y As Integer T: y = 10 U: Select Case y V: Case 1, 3, Is > 6 W: Print " Executed " X: End Select
- 以下语句正确的是:______。 A: Select Case a B: Case C: b=1 D: Case “B” E: b=2 F: Case Else G: b=3 H: End Select I: Select Case a J: Case “A” K: b=1 L: Case “B” M: b=2 N: Case Default O: b=3 P: End Select Q: Switch a R: Case “A” S: b=1 T: Case “B” U: b=2 V: Case Else W: b=3 X: End Switch Y: Switch a Z: Case “A” [: b=1 \: Case “B” ]: b=2 ^: Case Default _: b=3 `: End Select
- 下列计算最大公约数的递归过程,正确的是___________。 A: Sub gcd(ByVal m%, ByVal n%) Dim r% r = m n If r = 0 Then gcd = n Else gcd = gcd(n, r) End If End Sub B: Sub gcd(ByVal m%, ByVal n%) Dim r% r = m Mod n If r = 0 Then gcd = n Else gcd = gcd(n, r) End If End Sub C: Function gcd%(ByVal m%, ByVal n%) Dim r% r = m n If r = 0 Then gcd = n Else gcd = gcd(n, r) End If End Function D: Function gcd%(ByVal m%, ByVal n%) Dim r% r = m Mod n If r = 0 Then gcd = n Else gcd = gcd(n, r) End If End Function
- 下列程序运算后,Label1结果显示的是: Dim x As Integer Dim S As String x = 20 S = "2020" x = x Mod 3 Select Case x Case 0 Label1.Text = "A" Case 1 Label1.Text = "B" Case 2 Label1.Text = "C" Case Else Label1.Text = "D" End Select
内容
- 0
编写如下程序: Private Sub Command1_Click; Dim m As Integer, n As Integer m = 2 : n = 1 Select Case m Case 1 Select Case n Case 1 Print "AAA" Case 2 Print "BBB" End Select Case 2 Print "CCC" End Select End Sub 程序运行后,单击命令按钮Command1,输出结果为 A: BBB B: CCC C: AAA D: 1
- 1
已知十进制正整数 m,要转换成 r 进制字符串 s,完成此功能,如下过程头(子过程或函数过程)定义,不正确的是 。 A: Sub tran(ByVal m%, ByVal r%, ByRef s$) B: Sub tran(ByVal m%, ByVal r%, ByVal s$) C: Function s$(ByVal m%, ByVal r%) D: Function s$(ByVal r%, ByVal m%)
- 2
已知十进制正整数 m,要转换成 r 进制字符串 s,完成此功能,如下过程头(子过程或函数过程)定义,不正确的是 。 A: Sub tran(ByVal m%, ByVal r%, ByRef s$) B: Sub tran(ByVal m%, ByVal r%, ByVal s$) C: Function s$(ByVal m%, ByVal r%) D: Function s$(ByVal r%, ByVal m%)
- 3
下列程序的输出结果是 。 Private Sub exam1() a = 1 For i = 1 To 3 Select Case i Case 1, 3 a = a + 1 Case 2, 4 a = a + 2 End Select Next i MsgBox a End Sub
- 4
判断一个字符是字母字符、数字字符还是其他字符,并做相应的显示。字母字符显示字符串"字母";数字字符显示字符串"数字";其他字符显示字符串"其他"。 Private Sub Form_Click() Dim n As String n = InputBox("请输入一个字符") Select Case n Case "a" To "z", "A" To "Z" Print "字母" Case 【1】 Print "数字" Case Else Print "其他" End Select End Sub