加入标签Label1,Caption设置为“你好,请输入你的姓名”
加入文本框Text1,用来输入姓名的
加入标签Label2,按照你的要求设置字体属性,autosize属性设成true
分别加入确定,继续,结束按钮
以下是代码:
Private Sub Form_Load()
Me结束Visible = False
Me继续Visible = False
Label2Visible = False
End Sub
Private Sub 继续_Click()
Me结束Visible = False
Me继续Visible = False
Label2Visible = False
Me确定Visible = True
Label1Visible = True
Text1Visible = True
End Sub
Private Sub 结束_Click()
End
End Sub
Private Sub 确定_Click()
Label2Caption = Text1Text & "同学,你好,祝你学好vb程序设计"
Me结束Visible = True
Me继续Visible = True
Label2Visible = True
Label1Visible = False
Text1Visible = False
Me确定Visible = False
End Sub
Private
Sub
Form_Load()
Form2Width
=
ScreenWidth
05
Form2Height
=
ScreenWidth
05
屏幕一半
Form2Left
=
(ScreenWidth
-
Form2Width)
/
2
(屏幕宽-窗体宽)的一半
Form2Top
=
(ScreenHeight
-
Form2Height)
/
2
(
屏幕高-窗体高)的一半
两段加起来实现居中
End
Sub
和
Private
Sub
Form_Load()
Form2Width
=
ScreenWidth
05
Form2Height
=
ScreenWidth
05
同上
Form2Left
=
ScreenWidth
025
屏幕宽的025
Form2Top
=
ScreenHeight
025
屏幕高的025
不是居中
End
Sub
在桌面上,鼠标左键双击程序,在打开的VB6主界面上,左边是工具菜单栏,单击标签按钮,在Form1窗口上,绘制出一Label1,然后在其属性窗口上改个名字,如Caption为第一数,如下图所示。
接着,用同样的方法,在Form1窗口上绘制出第二数,并且在左边工具菜单栏,单击文本框按钮,并绘制出来。在文本框属性栏的Text属性上,将其Text1删除,也就是清空数据,如下图所示。
然后,反复用第一步骤和第二步骤做成如图所示的界面来,学习需要反复练习,在练习中不断进步。这里是做简单的加法程序,如下图所示。
接着,加法程序的界面做好后,还不能执行加法运算,必须还要在Form1窗口上绘制出一个命令按钮来,在左边工具菜单栏,单击命令按钮,并绘制出来。然后给其属性窗口下Caption改名为计算,如下图所示。
然后,程序看起来是做好了,单击如图所示的运行按钮,d出自己做出的Form1窗口,输入数字3和6,然后单击计算。可是结果并没有出现,如下图所示。
最后,前面5个步骤只是做了程序的界面,想要程序出结果,那必须加些代码了,既然是简单程序,只加一行代码就可以了。双击命令按钮,在代码窗口中输入如下:Text3Text = Val(Text1Text) + Val(Text2Text)后,再单击运行,输入数字,单击计算,此时就出现结果了,如下图所示。
你只要将以下代码复制到 "记事本"中另存为"成绩管理frm",再打开即可(不用添加控件,代码包含)谢谢,给分!
代码如下:
VERSION 500
Begin VBForm Form1
BorderStyle = 1 'Fixed Single
Caption = "成绩管理系统 V10"
ClientHeight = 3270
ClientLeft = 45
ClientTop = 435
ClientWidth = 4320
Icon = "成绩管理frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3270
ScaleWidth = 4320
StartUpPosition = 1 '所有者中心
Begin VBListBox List2
Height = 2760
ItemData = "成绩管理frx":0442
Left = 120
List = "成绩管理frx":0444
TabIndex = 15
Top = 360
Width = 1695
End
Begin VBTextBox KeMu
Height = 270
Index = 2
Left = 2040
Locked = -1 'True
TabIndex = 13
Top = 1680
Width = 855
End
Begin VBTextBox KeMu
Height = 270
Index = 1
Left = 2040
Locked = -1 'True
TabIndex = 11
Top = 1080
Width = 855
End
Begin VBTextBox KeMu
Height = 270
Index = 0
Left = 2040
Locked = -1 'True
TabIndex = 9
Top = 480
Width = 855
End
Begin VBTextBox Text2
Height = 270
Left = 2040
Locked = -1 'True
TabIndex = 8
Top = 2880
Width = 2055
End
Begin VBTextBox Text1
Height = 270
Left = 2040
Locked = -1 'True
TabIndex = 6
Top = 2280
Width = 2055
End
Begin VBCommandButton Command3
Caption = "修改(&S)"
Height = 375
Left = 3000
TabIndex = 4
Top = 1560
Width = 1215
End
Begin VBCommandButton Command2
Caption = "删除(&D)"
Height = 375
Left = 3000
TabIndex = 3
Top = 960
Width = 1215
End
Begin VBCommandButton Command1
Caption = "添加(&A)"
Height = 375
Left = 3000
TabIndex = 2
Top = 360
Width = 1215
End
Begin VBListBox List1
Enabled = 0 'False
Height = 2760
ItemData = "成绩管理frx":0446
Left = 120
List = "成绩管理frx":0448
TabIndex = 0
Top = 360
Visible = 0 'False
Width = 1695
End
Begin VBLabel Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Height = 180
Left = 3240
TabIndex = 16
Top = 0
Visible = 0 'False
Width = 930
End
Begin VBLabel Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "政 治:"
Height = 180
Index = 5
Left = 2040
TabIndex = 14
Top = 1440
Width = 630
End
Begin VBLabel Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "数 学:"
Height = 180
Index = 4
Left = 2040
TabIndex = 12
Top = 840
Width = 630
End
Begin VBLabel Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "语 文:"
Height = 180
Index = 3
Left = 2040
TabIndex = 10
Top = 240
Width = 630
End
Begin VBLabel Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "平均分:"
Height = 180
Index = 2
Left = 2040
TabIndex = 7
Top = 2640
Width = 630
End
Begin VBLabel Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "总 分:"
Height = 180
Index = 1
Left = 2040
TabIndex = 5
Top = 2040
Width = 630
End
Begin VBLabel Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "学生列表:"
Height = 180
Index = 0
Left = 120
TabIndex = 1
Top = 120
Width = 810
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'本程序由幻影工作室编写 >
以上就是关于怎么用vb做一个简单的程序全部的内容,包括:怎么用vb做一个简单的程序、简单vb程序、如何使用VB编写一个简单的小程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)