请用VB写一个小程序

请用VB写一个小程序,第1张

其实不是用循环那么复杂的,sum=1+2+3+n,也就是sum=n+(n_1)+3+2+1,sum+sum=(n+1)+[(n_1)+2]++(n+1)=n(n+1),最后把结果除以2,就可以了。n值用解方程的方式就可以了,最后把n值取整就行了

'取得CPU序列号

Private Type OSVERSIONINFO

dwOSVersionInfoSize As Long

dwMajorVersion As Long

dwMinorVersion As Long

dwBuildNumber As Long

dwPlatformId As Long

szCSDVersion As String 128 ' Maintenance string for PSS usage

End Type

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long

Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Const VER_PLATFORM_WIN32_NT = 2

Private Const VER_PLATFORM_WIN32_WINDOWS = 1

Private Const VER_PLATFORM_WIN32s = 0

Private Sub Form_Load()

Form1Hide

Dim len5 As Long, aa As Long

Dim cmprName As String

Dim osver As OSVERSIONINFO

'取得Computer Name

Open "cputxt" For Output As #1

cmprName = String(255, 0)

len5 = 256

aa = GetComputerName(cmprName, len5)

cmprName = Left(cmprName, InStr(1, cmprName, Chr(0)) - 1)

Computer = cmprName '取得CPU端口号

Set CPUs = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\cimv2")ExecQuery("select from Win32_Processor")

For Each mycpu In CPUs

Print #1, mycpuProcessorId

Next

Close #1

End

End Sub

这是在你的基础上改的,还有把form1的visible的值改为false

Dim a, b

Private Sub Command1_Click()

End

End Sub

Private Sub Form_Load()

TextText = "Visual Basic程序设计"

Command1Caption = "结束"

TextLeft = 0: TextTop = 0: TextWidth = 05 Form1Width

TextHeight = 05 Form1Height

a = Form1Width - Command1Left

b = Form1Height - Command1Top

End Sub

Private Sub Form_Resize()

TextLeft = 0: TextTop = 0: TextWidth = 05 Form1Width

TextHeight = 05 Form1Height

Command1Left = Form1Width - a

Command1Top = Form1Height - b

End Sub

注意,各变量名,控件名保持一致,你题目中的文本框名称为text

Private Sub Command1_Click()

'存储文本

Open AppPath & "\ctext" For Append As #1

Print #1, Text1Text

Close #1

End Sub

Private Sub Combo1_Change()

If Combo1List(Combo1ListIndex) = "条件" Then

Text1Text = "内容"

End If

End Sub

Private Sub Combo1_LostFocus()

Combo1AddItem Combo1Text

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Label1ForeColor = vbBlack

End Sub

Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Label1ForeColor = &H0&

End Sub

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Label1ForeColor = vbGreen

End Sub

Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Label1ForeColor = vbWhite

End Sub

Private Sub Timer1_Timer()

If Time = "07:00:00" Then MsgBox "cccc"

End Sub

我这边回不了你的问题,不能回答,也不能发文件

你发你发油箱,我从邮箱或者QQ发给你

变量定义面变量名x,y换别x1y1等

Dim

x1

As

Integer

Private

Sub

Command1_Click()'+按钮

x1

=

x1

+

1

MeCaption

=

x1

End

Sub

Private

Sub

Command2_Click()'-按钮

x1=

x1

-

1

MeCaption

=

x1

End

Sub

Dim sec, min, h

Private Sub Command1_Click()

Timer1Enabled = True

h = Text1Text

min = Text2Text

sec = Text3Text

Timer2Enabled = False

End Sub

Private Sub Command2_Click()

End

End Sub

Private Sub Form_Load()

Form1BackColor = &HFFFF00

Timer1Enabled = False

Timer1Interval = 1000

Timer2Enabled = True

Timer2Interval = 1000

Text1Text = 2

Text2Text = "00"

Text3Text = "00"

Command2Caption = "退出"

Command1Caption = "开始倒计时"

End Sub

Private Sub Timer1_Timer()

If sec > 0 Then

sec = sec - 1

Else:

If (min > 0 Or h > 0) Then

sec = 59

End If

If min > 0 Then

min = min - 1

Else:

If h > 0 Then

min = 59

End If

If h > 0 Then

h = h - 1

Else: Timer1Enabled = False

CreateObject("SAPISpVoice")Speak "GAME OVER!"

Form1BackColor = &HFF

End If

End If

End If

Text1Text = h

Text2Text = min

Text3Text = sec

Label6Caption = Now

End Sub

Private Sub Timer2_Timer()

Label6Caption = Now

End Sub

欢迎分享,转载请注明来源:表白网

原文地址:https://h5.hunlipic.com/biaobai/2883173.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2024-01-18
下一篇2024-01-18

发表评论

登录后才能评论

评论列表(0条)

    保存