用VB做一个简单的小程序

用VB做一个简单的小程序,第1张

Private Sub Command1_Click()

  MeCls

  Dim N As Integer, i As Integer

  N = InputBox("n=", , 9)

  For i = 1 To 2  N - 1

    If i <= N Then

      Print Space(N - i) + String(2  i - 1, CStr(i))

    Else

      Print Space(N - (2  N - i)) + String(2  (2  N - i) - 1, CStr(2  N - i))

    End If

  Next i

End Sub

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

form1上放置Command1,Timer1,Picture1(装入一个)

Dim MoveStep As Integer

Private Sub Command1_Click()

Timer1Enabled = False

End Sub

Private Sub Form_Load()

MoveStep = 100

End Sub

Private Sub Timer1_Timer()

If Picture1Left + Picture1Width + 30 > Form1Width Then

MoveStep = -100

End If

If Picture1Left < 0 Then

MoveStep = 100

End If

Picture1Left = Picture1Left + MoveStep

End Sub

新建一个文本框Text1,Text属性为空,MultiLine属性为True,ScrollBars属性为2。

新建一个命令按钮Command1,添加以下代码:

Private Sub Command1_Click()

Dim i As Integer

For i = 1 To 100

If (i Mod 5 = 0) And (i Mod 3 <> 0) Then Text1Text = Text1Text & vbCrLf & i

Next

End Sub

'取得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

以上就是关于用VB做一个简单的小程序全部的内容,包括:用VB做一个简单的小程序、用VB编写一个小程序、怎样用 VB 制作个简单的小程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/9839011.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-02
下一篇 2023-05-02

发表评论

登录后才能评论

评论列表(0条)

保存