放置一个command1,一个text1,一个label1,使用它们默认的名字,控件的位置和大小不用设定,程序会自动设定。代码如下:
Private Sub Command1_Click()
Dim N As Long, I As Long, J As Long, K As Long
If IsNumeric(Text1Text) Then
N = CLng(Text1Text)
If N Mod 1 = 0 And N >= 9 Then
For I = 3 To N \ 2
If Pd(I) Then
For J = 3 To N - I
If Pd(J) Then
K = N - I - J
If Pd(K) Then
Label1Caption = "结果: " & N & "=" & I & "+" & J & "+" & K & "符合!"
Exit Sub
End If
End If
Next
End If
Next
Label1Caption = "结果: 不符合!"
Else
Text1Text = "请输入大于或等于9的奇数!"
End If
Else
Text1Text = "请输入数字!"
End If
End Sub
Private Sub Form_Click()
Cls
Print "双击退出"
Command1Visible = True
Text1Visible = True
Label1Visible = True
End Sub
Private Sub Form_DblClick()
End
End Sub
Private Sub Form_Load()
Form1Caption = "哥德巴赫猜想"
Form1Width = 5000
Form1Height = 5000
Form1AutoRedraw = True
Text1Text = "在此输入一个大于等于9的奇数!"
Text1ForeColor = &H808080
Text1Top = 500
Text1Left = 200
Text1Width = 3000
Text1Height = 300
Text1Visible = False
Label1Caption = ""
Label1Top = 1000
Label1Left = 200
Label1Width = 3000
Label1Height = 300
Label1Visible = False
Command1Caption = "验证"
Command1Top = 2000
Command1Left = 200
Command1Width = 800
Command1Height = 300
Command1Visible = False
Print "1942年德国数学家哥德巴赫给数学家欧拉的一封信中,"
Print "提出了把一个整数表示成两个素数之和的推测,"
Print "也描述为:每个不小于9的奇数都可以表示为三个奇素数之和。 "
Print "本Visual Basic程序用来验证这一猜想,让我们开始吧!"
Print "单击开始"
Form1Show
End Sub
Private Sub Text1_GotFocus()
Text1Text = ""
Text1ForeColor = &H0
Command1Visible = True
End Sub
Function Pd(a As Long) As Boolean
Dim b As Long
For b = 2 To a - 1
DoEvents
If a Mod b = 0 Then
Pd = False
Exit For
Else
Pd = True
End If
Next
End Function
'已经运行过
楼主你好,关于VB验证的生成
我空间有介绍
>
看是否运行:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command5_Click()
Dim lHwnd As Long
lHwnd = FindWindow(vbNullString, "程序的Title或Caption")
If lHwnd <> 0 Then
MsgBox "程序正在运行!"
End If
End Sub
向它发送指令:
AppActivate "程序的Title或Caption"
SendKeys "指令"
要启动程序:
Call Shell("完整路径和程序名称exe")
以上就是关于求输入一个数,验证哥德巴赫猜想的vb程序全部的内容,包括:求输入一个数,验证哥德巴赫猜想的vb程序、如何用vb的编程来编写验证码的程序、VB 如何检测一个程序是否在运行中等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)