1、VB程序设计以Visual Basic 60简体中文版为语言背景,深入浅出的介绍Visual Basic 60程序设计技术,基本涵盖了Visual Basic 60编程时的常用内容。
2、VB程序设计共分14章,主要内容包括开发环境、语言基础和数组与过程、常用控件、菜单设计、文件处理、ActiveX控件、数据库程序设计、图形程序设计、多媒体编程、网络编程、API函数和注册表、安装程序的制作和综合实例。
3、为了方便读者学习,《VB程序设计》提供多媒体课件,及例题和练习题的所有源代码。
4、VB程序设计可以作为大中专院校计算机及相关专业的教材,适合编程爱好者自学使用。
'这个很简单的了,你用记事本把这段代码复制过去,然后另存为frm就可以了
'然后用vb打开。看看效果。
'以下保存为 任务名称frm
VERSION 500
Begin VBForm Form1
Caption = "计算机"
ClientHeight = 4230
ClientLeft = 60
ClientTop = 750
ClientWidth = 3165
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4230
ScaleWidth = 3165
StartUpPosition = 2 '屏幕中心
Begin VBFrame Frame1
Height = 3495
Left = 120
TabIndex = 1
Top = 600
Width = 2895
Begin VBCommandButton cmdResult
Caption = "="
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1080
TabIndex = 20
Top = 3000
Width = 1695
End
Begin VBCommandButton cmdOff
Caption = "OFF"
Height = 375
Left = 1560
TabIndex = 19
Top = 240
Width = 495
End
Begin VBCommandButton cmdCE
Caption = "CE"
Height = 375
Left = 2280
TabIndex = 18
Top = 240
Width = 495
End
Begin VBCommandButton cmdchu
Caption = "/"
Height = 375
Left = 2280
TabIndex = 17
Top = 2520
Width = 495
End
Begin VBCommandButton cmdjia
Caption = "+"
Height = 375
Left = 2280
TabIndex = 16
Top = 720
Width = 495
End
Begin VBCommandButton cmd0
Caption = "0"
Height = 375
Left = 840
TabIndex = 15
Top = 2520
Width = 495
End
Begin VBCommandButton cmd6
Caption = "6"
Height = 375
Left = 1560
TabIndex = 14
Top = 1320
Width = 495
End
Begin VBCommandButton cmd8
Caption = "8"
Height = 375
Left = 840
TabIndex = 13
Top = 720
Width = 495
End
Begin VBCommandButton cmd4
Caption = "4"
Height = 375
Left = 120
TabIndex = 12
Top = 1320
Width = 495
End
Begin VBCommandButton cmd9
Caption = "9"
Height = 375
Left = 1560
TabIndex = 11
Top = 720
Width = 495
End
Begin VBCommandButton cmd2
Caption = "2"
Height = 375
Left = 840
TabIndex = 10
Top = 1920
Width = 495
End
Begin VBCommandButton cmdjian
Caption = "-"
Height = 375
Left = 2280
TabIndex = 9
Top = 1320
Width = 495
End
Begin VBCommandButton cmdPoint
Caption = ""
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1560
TabIndex = 8
Top = 2520
Width = 495
End
Begin VBCommandButton cmdcheng
Caption = ""
Height = 375
Left = 2280
TabIndex = 7
Top = 1920
Width = 495
End
Begin VBCommandButton cmd5
Caption = "5"
Height = 375
Left = 840
TabIndex = 6
Top = 1320
Width = 495
End
Begin VBCommandButton cmd3
Caption = "3"
Height = 375
Left = 1560
TabIndex = 5
Top = 1905
Width = 495
End
Begin VBCommandButton cmd1
Caption = "1"
Height = 375
Left = 120
TabIndex = 4
Top = 1920
Width = 495
End
Begin VBCommandButton cmd7
Caption = "7"
Height = 375
Left = 120
TabIndex = 3
Top = 720
Width = 495
End
Begin VBCommandButton cmdChange
Caption = "+/-"
Height = 375
Left = 120
TabIndex = 2
Top = 2520
Width = 495
End
End
Begin VBTextBox txt
Alignment = 1 'Right Justify
Enabled = 0 'False
BeginProperty Font
Name = "宋体"
Size = 105
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
Locked = -1 'True
TabIndex = 0
Top = 120
Width = 2895
End
Begin VBMenu meuFile
Caption = "文件(&F)"
Begin VBMenu meuExit
Caption = "退出(&X)"
Shortcut = ^X
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim XiaoShu As Boolean
'在窗体变量中声明一个布尔值来判断是否按下了小数点键,防止txt中出现多个小数。如果已经输入了小数点则Xiaoshu为True,否则为False
Dim FuHao As Byte
'声明一个Byte来记录我们按下了什么符号,1为"+",2为"-",3为"",4为"/"
Dim FirstNumber As Double
'声明一个变量来记录 *** 作数的第一个数,如A+B,那么FirstNumber来记下A的值。
Dim DengHao As Boolean
'声明一个变量来记录是否按下了=号,如果按下了则为True
Private Sub cmd0_Click()
If txtText <> "" Then txtText = txtText + "0" '防止多个0在文本中出现
End Sub
Private Sub cmd1_Click() '按下1时
If Not DengHao Then '没按下等号
txtText = txtText + "1"
Else
txtText = "1" '按下了等号
DengHao = False
End If
End Sub
Private Sub cmd2_Click() '按下2时
If Not DengHao Then '没按下等号
txtText = txtText + "2"
Else
txtText = "2" '按下了等号
DengHao = False
End If
End Sub
Private Sub cmd3_click() '按下3时
If Not DengHao Then '没按下等号
txtText = txtText + "3"
Else
txtText = "3" '按下了等号
DengHao = False
End If
End Sub
Private Sub cmd4_Click() '按下4时
If Not DengHao Then '没按下等号
txtText = txtText + "4"
Else
txtText = "4" '按下了等号
DengHao = False
End If
End Sub
Private Sub cmd5_Click() '按下5时
If Not DengHao Then '没按下等号
txtText = txtText + "5"
Else
txtText = "5" '按下了等号
DengHao = False
End If
End Sub
Private Sub cmd6_Click() '按下6时
If Not DengHao Then '没按下等号
txtText = txtText + "6"
Else
txtText = "6" '按下了等号
DengHao = False
End If
End Sub
Private Sub cmd7_Click() '按下7时
If Not DengHao Then '没按下等号
txtText = txtText + "7"
Else
txtText = "7" '按下了等号
DengHao = False
End If
End Sub
Private Sub cmd8_Click() '按下8时
If Not DengHao Then '没按下等号
txtText = txtText + "8"
Else
txtText = "8" '按下了等号
DengHao = False
End If
End Sub
Private Sub cmd9_Click() '按下9时
If Not DengHao Then '没按下等号
txtText = txtText + "9"
Else
txtText = "9" '按下了等号
DengHao = False
End If
End Sub
Private Sub cmdCE_Click()
txtText = ""
XiaoShu = False
End Sub
Private Sub cmdChange_Click()
If (Sgn(Val(txtText))) = 1 Then txtText = "-" + txtText: Exit Sub '用Sgn来判断txt文本框内的值的符号。大于0的话就在前面加上"-"
If (Sgn(Val(txtText))) = -1 Then txtText = Abs(Val(txtText)) 'txt文本框的文本为大于0的数txt前面的"-"去掉。
End Sub
Private Sub cmdcheng_Click()
FirstNumber = Val(txtText)
FuHao = 3
txtText = ""
XiaoShu = False
End Sub
Private Sub cmdchu_Click()
FirstNumber = Val(txtText)
FuHao = 4
txtText = ""
XiaoShu = False
End Sub
Private Sub cmdjia_Click()
FirstNumber = Val(txtText)
FuHao = 1
txtText = ""
XiaoShu = False
End Sub
Private Sub cmdjian_Click()
FirstNumber = Val(txtText)
FuHao = 2
txtText = ""
XiaoShu = False
End Sub
Private Sub cmdOff_Click()
End
End Sub
Private Sub cmdPoint_Click()
If txtText = "" Then txtText = "0"
If Not XiaoShu Then '当我们以前没有按下小数点键时在txt中加上小数点
txtText = txtText + ""
XiaoShu = True
End If
End Sub
Private Sub cmdResult_Click()
If FuHao = 1 Then '按下了+号
txtText = FirstNumber + Val(txtText)
End If
If FuHao = 2 Then '按下了-号
txtText = FirstNumber - Val(txtText)
End If
If FuHao = 3 Then '按下了号
txtText = FirstNumber Val(txtText)
End If
If FuHao = 4 Then '按下了、号
txtText = FirstNumber / Val(txtText)
End If
DengHao = True '记录下按了=号
XiaoShu = False
End Sub
Private Sub meuExit_Click()
End
End Sub
VB 是Visual Basic编程语言
编写计算机程序需要使用计算机编程语言。计算机编程语言是人和计算机“对话”的桥梁。就像人类的语言一样,计算机编程语言也有很多。目前较为广泛使用的语言有“C++”、“Pascal”、“Basic”等。在众多的计算机编程语言中,以BASIC语言最为易学易用。
BASIC是英文Beginner’s All purpose Symbolic Instruction Code的缩写,意思为初学者通用符号指令代码,一直都是程序设计入门的首选语言。
1991年,Visual Basic(简称VB)面世,他是第三代BASIC语言,它不但秉承了BASIC语言的易学易用的优点,而且增加了图形界面设计工具。它简化了复杂的窗口程序编写过程,让编程者将更多的精力致力于问题的求解过程。
窗体上放Text1、Text2、Text3、Command1
按下command1,text3里显示text1里的数字加上text2里的数字。
代码:
Private Sub Command1_Click()text3 = val(text1) + val(text2)
End Sub
以上就是关于vb程序设计是什么全部的内容,包括:vb程序设计是什么、用VB设计一个计算器、vb是一个什么电脑软件,它有什么用途等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)