題目:某公司的電話語音系統中,欲輸入英文字母A時,需案01,欲輸入英文字母B時,需按02,欲輸入英文字母C時,需按03,可將使用者所輸入字母依此類推,共26個英文字母,請設計一函數,可將使用者所輸入之二位數字轉成大寫的英文字母。(為求執行效率起見,程式碼勿超過6行)謝謝!
2006-06-16 20:38:18 · 4 個解答 · 發問者 Anonymous in 電腦與網際網路 ➔ 程式設計
一行就可以搞定了吧?Private Function NumToLetter(ByVal Number as Integer) as String If Number >=1 and Number <=26 Then NumToLetter = Chr(Number+64)End Function
2006-06-20 22:04:34 補充:
哈哈哈~~~ 結果是答在意見欄中的WJS大大的code 考慮得最完善.... ^O^
2006-06-17 21:42:16 · answer #1 · answered by 憂鬱的貢丸湯 5 · 0⤊ 0⤋
哈哈!大家都來了,嗯...樓主好像說要輸入二位數字~"~
Function Num2L(ByVal S As String) As String
If IsNumeric(S) And Len(S) = 2 And InStr(S, ".") = 0 Then
If Val(S) > 0 And Val(S) < 27 Then Num2L = Chr(Val(S) + 64)
End If
End Function
2006-06-19 11:48:39 · answer #2 · answered by W.J.S. 7 · 0⤊ 0⤋
Function num_eng(ByVal num As String) If Val(num) >= 1 And Val(num) <= 26 Then num_eng = Chr(Val(num) + 64) Else num_eng = Null End IfEnd Function
2006-06-17 17:48:13 · answer #3 · answered by 世賢 7 · 0⤊ 0⤋
函數:Private Sub Command1_Click()
Function xChr(ByVal intInNum)
If intInNum >= 1 And intInNum <= 26 Then
xChr = Chr(64 + intInNum)
End If
End Function
使用範例:
Private Sub Command1_Click()
For i = 1 To 26
Print xChr(i);
Next
End Sub
2006-06-16 21:00:39 · answer #4 · answered by ? 4 · 0⤊ 0⤋