2、KeyAscii >=48 AND KeyAscii <=57
3、Text2.Text &Chr(KeyAscii)
以上是在Text2上将每次符合条件轿键的字符都依次连接起来显示。如果是每次要在Text2上只显示一团庆个字符,则将第3空闭或巧改为:
Chr(KeyAscii)
''1、将输入字符串“abcdef”输出为”fedcba”Private Sub Invert(ByVal xStr As String, yStr As String)
Dim tempStr As String
Dim I As Integer
I = Len(xStr)
Do While I >= 1
tempStr = tempStr + Mid(xStr, I, 1)
I = I - 1
Loop
yStr = tempStr
End Sub
Private Sub Form_Click()
Dim s1 As String, s2 As String
s1 = "abcdef"
Call Invert(s1, s2)
Print s2
End Sub
''2、如果两个质数的差为2,就称这两个质数为质数对,输出100以内的质数对
Public Function IsP(m As Integer) As Boolean
Dim I As Integer
IsP = True
For I = 2 To Int(Sqr(m))
If m Mod I = 0 Then
IsP = False
Exit For
End If
Next I
End Function
Private Sub Form_Click()
Dim I As Integer
p1 = IsP(3)
For I = 5 To 100 Step 2
p2 = IsP(I)
If p1 And p2 Then Print I - 2, I
p1 = p2
Next I
End Sub
'3、求解一元二次方程猜升,要求a,b,c及解x1,x2都以参数传递的方式与主程序交换数据,输入a,b,c和输出带轮x1,x2的 *** 作都放在主程序中
Sub Equa(A!, B!, C!, x1$, x2$)
If Abs(A) <= 0.000001 Then
MsgBox ("不能构成方程"): Exit Sub
Else
Disc = B * B - 4 * A * C
End If
If Abs(Disc) <= 0.000001 Then
Flag = 1
MsgBox ("方程有等实根")
x1 = -B / (2 * A)
x2 = -B /穗行老 (2 * A)
ElseIf Disc >0.000001 Then
Flag = 2: MsgBox ("方程有两不等实根")
x1 = (-B + Sqr(Disc)) / (2 * A)
x2 = (-B - Sqr(Disc)) / (2 * A)
Else
Flag = 3: MsgBox ("方程有两虚实根")
Realp = (-B) / (2 * A)
imagep = Abs(Disc) / (2 * A)
x1 = Realp &"+" &imagep &"I"
x2 = Realp &"-" &imagep &"I"
End If
End Sub
Private Sub Form_Click()
Dim x1$, x2$
A! = InputBox("输入A值")
B! = InputBox("输入B值")
C! = InputBox("输入C值")
Call Equa(A, B, C, x1, x2)
Print x1, x2
End Sub
1.Long(可以存储更大的数)明耐Integer 也行哦激返春2.While n >世源 0
3.1 To n
4.f = -f : s = S + f / i
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)