
'取得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
代码改为:Private Sub Form_Click()Dim a, b, c, d As StringDim sum, aver As Longa = Val(InputBox("请输入第一个数"))
b = InputBox("请输入第二个数")
c = InputBox("请输入第三个数")
d = InputBox("请输入第四个数")
sum = a + b + c + d
aver = sum / 4
Print "所输入的4个数字分别是"; a, b, c, d
Print "4个数字的和为"; sum
Print "4个数字的平均值为"; averEnd Sub VB60下调试通过。
用VBnet制作一个小程序(1)
----制作“HelloNET”程序
作者:高山
用下面很简单的方法,就可以制作一个“HelloNET”小程序,同时可以掌握一些控件的用法。
Public Class Form1
Inherits SystemWindowsFormsForm
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBaseNew()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
componentsDispose()
End If
End If
MyBaseDispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As SystemComponentModelIContainer
'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Button1 As SystemWindowsFormsButton
Friend WithEvents TextBox1 As SystemWindowsFormsTextBox
<SystemDiagnosticsDebuggerStepThrough()> Private Sub InitializeComponent()
MeButton1 = New SystemWindowsFormsButton()
MeTextBox1 = New SystemWindowsFormsTextBox()
MeSuspendLayout()
'
'Button1
'
MeButton1Location = New SystemDrawingPoint(16, 112)
MeButton1Name = "Button1"
MeButton1TabIndex = 0
MeButton1Text = "OK"
'
'TextBox1
'
MeTextBox1Location = New SystemDrawingPoint(160, 112)
MeTextBox1Name = "TextBox1"
MeTextBox1TabIndex = 1
MeTextBox1Text = ""
'
'Form1
'
MeAutoScaleBaseSize = New SystemDrawingSize(6, 14)
MeClientSize = New SystemDrawingSize(292, 266)
MeControlsAddRange(New SystemWindowsFormsControl() {MeTextBox1, MeButton1})
MeName = "Form1"
MeText = "Hello,VBNET"
MeResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As SystemObject, ByVal e As SystemEventArgs) Handles Button1Click
TextBox1Text = "Hello,VBNET!"
End Sub
End Class
楼主您好!
代码如下:
Option ExplicitPrivate Sub Command1_Click()
Dim n(7) As Double
Dim k(3) As Double
k(3) = 1
Dim j As Integer
For j = 1 To 7
n(j) = Val(Controls("Text" & CStr(j))Text)
Next j
For j = 1 To 7
k(1) = k(1) + n(j)
k(2) = k(2) - n(j)
k(3) = k(3) n(j)
Next j
MeText8Text = "7个数的和为:" & k(1) & vbCrLf & _
"7个数的差为:" & k(2) & vbCrLf & _
"7个数的乘积为:" & k(3)
End Sub
Private Sub Command2_Click()
Dim i As Integer
For i = 1 To 8
Controls("Text" & CStr(i))Text = ""
Next i
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 8
Controls("Text" & CStr(i))Text = ""
Next i
End Sub
VC++
C#
VB都可以编写(好像系统自带的程序
微软另有一套语言来编写)
语言只是一种工具
对小规模的程序而言
各种语言很容易取得一模一样的功能效果
这些小程序小游戏全可以用VB写(感兴趣的话可以自己试试:)
多查些资料
构思算法
编程不难的)
1新建标准exe工程,打开界面
2插入需要的元件,双击元件编写代码。
3运行代码并完善代码。
4保存:
(1)找到{文件}中的{保存},保存后还可继续编辑。
(2)找到{文件}中的{生成exe},保存后成为一个真正的exe程序,可脱离VB环境使用。
下面是一些简单的语句
例1
Private Sub Form1 _Click
MsgBox "文件错误",,"提示"
End Sub
效果:点击窗口后d出提示窗。
例2
Private Sub Form1 _Click
Dim m , n , a As Single
m = InputBox ("输入m的值","计算")
n = InputBox ("输入n的值",,"计算")
a = m n
MsgBox "计算结果"+a ,,"计算"
End Sub
效果:鼠标点击窗口后会提示分别输入m和n的值,然后出现它们的乘积。
以上就是关于用VB写一个小程序全部的内容,包括:用VB写一个小程序、VB编写小程序、谁知道怎样用VB制作小程序(具体步骤最好有图)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)