Dim n As Integer Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then n = 0 Dim s As String s = Text1.Text For i = 1 To Len(s) If Val(Mid(s, i, 1)) Mod 2 <> 0 Then n = n + 1 End If Next i Text2.Text = n End If End Sub
Private Sub Command1_Click() '调用实例 Dim str As String MsgBox return_str(5) End Sub Private Function return_str(number As Integer) As String '通用函数 Dim str As String For i = 1 To number Dim str_temp As String str_temp = "" ' MsgBox str_temp For j = 1 To i str_temp = str_temp & CStr(i) Next
str = str & str_temp Next return_str = str End Function本回答被网友采纳