vb简单的计算机源代码
VB简易计算器代码
VB简易计算器代码下面是一个简单的VB计算器代码,用于执行基本的加、减、乘、除运算。
```vbOption Strict OnPublic Class CalculatorPrivate Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.ClickDim num1 As Double = CDbl(txtNum1.Text)Dim num2 As Double = CDbl(txtNum2.Text)Dim result As Double = num1 + num2txtResult.Text = result.ToStringEnd SubPrivate Sub btnSubtract_Click(sender As Object, e As EventArgs) Handles btnSubtract.ClickDim num1 As Double = CDbl(txtNum1.Text)Dim num2 As Double = CDbl(txtNum2.Text)Dim result As Double = num1 - num2txtResult.Text = result.ToStringPrivate Sub btnMultiply_Click(sender As Object, e As EventArgs) Handles btnMultiply.ClickDim num1 As Double = CDbl(txtNum1.Text)Dim num2 As Double = CDbl(txtNum2.Text)Dim result As Double = num1 * num2txtResult.Text = result.ToStringEnd SubPrivate Sub btnDivide_Click(sender As Object, e As EventArgs) Handles btnDivide.ClickDim num1 As Double = CDbl(txtNum1.Text)Dim num2 As Double = CDbl(txtNum2.Text)If num2 = 0 ThenMessageBox.Show("除数不能为0!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)ElseDim result As Double = num1 / num2txtResult.Text = result.ToStringEnd IfEnd Sub```此代码创建了一个简单的窗体应用程序,其中包含两个文本框用于输入两个数字,四个按钮用于执行不同的计算操作,以及一个文本框用于显示结果。
VB简易计算器代码
VB简易计算器代码以下是一个简单的VB计算器代码:```Public Class Form1Dim firstNum As Double ' 第一个数字Dim secondNum As Double ' 第二个数字Dim operation As Integer ' 1-加法,2-减法,3-乘法,4-除法Private Sub Button0_Click(sender As Object, e As EventArgs) Handles Button0.ClickTextBoxResult.Text = TextBoxResult.Text & "0"End SubPrivate Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.ClickTextBoxResult.Text = TextBoxResult.Text & "1"End SubPrivate Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.ClickTextBoxResult.Text = TextBoxResult.Text & "2"End SubHandles Button3.ClickTextBoxResult.Text = TextBoxResult.Text & "3"End SubPrivate Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.ClickTextBoxResult.Text = TextBoxResult.Text & "4"End SubPrivate Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.ClickTextBoxResult.Text = TextBoxResult.Text & "5"End SubPrivate Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.ClickTextBoxResult.Text = TextBoxResult.Text & "6"End SubPrivate Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.ClickTextBoxResult.Text = TextBoxResult.Text & "7"End SubHandles Button8.ClickTextBoxResult.Text = TextBoxResult.Text & "8"End SubPrivate Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.ClickTextBoxResult.Text = TextBoxResult.Text & "9"End SubPrivate Sub ButtonDot_Click(sender As Object, e As EventArgs) Handles ButtonDot.ClickIf Not TextBoxResult.Text.Contains(".") ThenTextBoxResult.Text = TextBoxResult.Text & "."End IfEnd SubPrivate Sub ButtonAdd_Click(sender As Object, e As EventArgs) Handles ButtonAdd.ClickfirstNum = Double.Parse(TextBoxResult.Text)TextBoxResult.Text = ""operation = 1End SubPrivate Sub ButtonSubtract_Click(sender As Object, e As EventArgs) Handles ButtonSubtract.ClickfirstNum = Double.Parse(TextBoxResult.Text)TextBoxResult.Text = ""operation = 2End SubPrivate Sub ButtonMultiply_Click(sender As Object, e As EventArgs) Handles ButtonMultiply.ClickfirstNum = Double.Parse(TextBoxResult.Text)TextBoxResult.Text = ""operation = 3End SubPrivate Sub ButtonDivide_Click(sender As Object, e As EventArgs) Handles ButtonDivide.ClickfirstNum = Double.Parse(TextBoxResult.Text)TextBoxResult.Text = ""operation = 4End SubPrivate Sub ButtonClear_Click(sender As Object, e As EventArgs) Handles ButtonClear.ClickTextBoxResult.Text = ""End SubPrivate Sub ButtonEquals_Click(sender As Object, e As EventArgs) Handles ButtonEquals.ClickDim result As DoublesecondNum = Double.Parse(TextBoxResult.Text)Select Case operationCase 1result = firstNum + secondNumCase 2result = firstNum - secondNumCase 3result = firstNum * secondNumCase 4result = firstNum / secondNumEnd SelectTextBoxResult.Text = result.ToStringEnd SubEnd Class```这个计算器包括数字按钮0-9、小数点按钮、加法、减法、乘法、除法和等于按钮。
vb简单的计算机源代码
vb简单的计算机源代码.txt如果xx的时光在闲散中度过,那么回忆岁月将是一场凄凉的悲剧。
杂草多的地方庄稼少,空话多的地方xx少。
即使路上没有花朵,我仍可以欣赏荒芜。
Private Sub Command1_Click()Form1.Caption = "欢迎使用智能计算器"'载入默认正常显示If Check1.Value = "0" Then'1类分歧ElseIf Text1.Text = "" Or Text2.Text = "" Then'2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then'2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"Else'2类分歧Dim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a + bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" Then'1类分歧ElseIf Text1.Text = "" Or Text2.Text = "" Then'2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then'2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"Else'2类分歧Dim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d + eText3.Text = fEnd IfEnd SubPrivate Sub Command2_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d - eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a - bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub Command3_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d * eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a * bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub Command4_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "分数的分子不能为零"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a / bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "分数的分子不能为零"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d / eText3.Text = fEnd IfEnd SubPrivate Sub Command5_Click()Form1.Caption = "欢迎使用智能计算器" Text1.Text = ""Text2.Text = ""Text3.Text = ""End SubPrivate Sub Command6_Click()Form1.HideForm3.ShowEnd SubPrivate Sub Command7_Click()EndEnd SubPrivate Sub Command8_Click()Form1.Caption = "欢迎使用智能计算器" If Text3.Text <> "" ThenText1.Text = Text3.TextText2.Text = ""Text3.Text = ""ElseForm1.Caption = "xataliq kuruldi"Text3.Text = "没有结果无法继续"End IfEnd SubPrivate Sub Text2_Change()End SubPrivate Sub 乘_Click()If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d * eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a * bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub 除_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "分数的分子不能为零"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a / bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "错误"Text3.Text = "分数的分子不能为零"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d / eText3.Text = fEnd IfEnd SubPrivate Sub munasiwetlik_Click()Form1.Caption = "欢迎使用智能计算器" Form1.HideForm3.ShowEnd SubPrivate Sub 继续_Click()Form1.Caption = "欢迎使用智能计算器" If Text3.Text <> "" ThenText1.Text = Text3.TextText2.Text = ""Text3.Text = ""ElseForm1.Caption = "xataliq"Text3.Text = "没有结果无法继续"End IfEnd SubPrivate Sub 加_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a + bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d + eText3.Text = fEnd IfEnd SubPrivate Sub 减_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d - eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)Text3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub 清空_Click()Form1.Caption = "欢迎使用智能计算器" Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub----------------------------------------------form2Private Sub Command1_Click()Form3.HideForm1.ShowForm1.Text3.Text = ""End SubPrivate Sub Command2_Click()End。
vb简易计算器源码
vb简易计算器源码代码如下:复制代码代码如下:/***Author:乌鸟heart*Version:1.0*/Dim IntX As Double '全局变量,⽤于存储计算的数值Dim IntOperation As Double '标记运算类型Dim isBegin As Boolean '标记是否已经给IntX赋值Public Sub Clear() '清空命令函数screen.Caption = ""End SubPublic Sub SavaToIntX()Select Case IntOperationCase 1 '加法If isBegin = False ThenIntX = Val(screen.Caption)isBegin = TrueElseIntX = IntX + Val(screen.Caption)End IfCase 2 '减法If isBegin = False ThenIntX = Val(screen.Caption)isBegin = TrueElseIntX = IntX - Val(screen.Caption)End IfCase 3 '乘法If isBegin = False ThenIntX = Val(screen.Caption)isBegin = TrueElseIntX = IntX * Val(screen.Caption)'screen.Caption = IntXEnd IfCase 4 '除法If isBegin = False ThenIntX = Val(screen.Caption)isBegin = TrueElseIntX = IntX / Val(screen.Caption)End IfEnd SelectEnd SubPrivate Sub Command0_Click()screen.Caption = screen.Caption & 0End SubPrivate Sub Command1_Click()screen.Caption = screen.Caption & 1End SubPrivate Sub Command2_Click()screen.Caption = screen.Caption & 2End SubPrivate Sub Command3_Click()screen.Caption = screen.Caption & 3End SubPrivate Sub Command4_Click()screen.Caption = screen.Caption & 4End SubPrivate Sub Command5_Click()screen.Caption = screen.Caption & 5End SubPrivate Sub Command6_Click()screen.Caption = screen.Caption & 6End SubPrivate Sub Command7_Click()screen.Caption = screen.Caption & 7End SubPrivate Sub Command8_Click()screen.Caption = screen.Caption & 8End SubPrivate Sub Command9_Click()screen.Caption = screen.Caption & 9End SubPrivate Sub CommandClear_Click() '清空命令isBegin = FalseIntOperation = 0IntX = 0screen.Caption = ""End SubPrivate Sub CommandEqual_Click() '等号运算If IntOperation <> 0 Then '有运算标记的情况Call SavaToIntXIntOperation = 0isBegin = Falsescreen.Caption = IntXEnd IfEnd SubPrivate Sub CommandMinus_Click() '减法运算If IntOperation <> 0 Then '有运算标记的情况Call SavaToIntXIntOperation = 2Call ClearElseIntOperation = 2Call SavaToIntXCall ClearEnd IfEnd SubPrivate Sub CommandMultiple_Click() '乘法运算If IntOperation <> 0 Then '有运算标记的情况Call SavaToIntXIntOperation = 3Call ClearElseIntOperation = 3Call SavaToIntXCall ClearEnd IfEnd SubPrivate Sub CommandPlus_Click() '加法运算If IntOperation <> 0 Then '有运算标记的情况Call SavaToIntXIntOperation = 1Call ClearElseIntOperation = 1Call SavaToIntXCall ClearEnd IfEnd SubPrivate Sub CommandSlash_Click() '除法运算If IntOperation <> 0 Then '有运算标记的情况Call SavaToIntXIntOperation = 4Call ClearElseIntOperation = 4Call SavaToIntXCall ClearEnd IfEnd Sub。
vb编程代码大全
vb编程代码大全Visual Basic (VB) 是一种广泛用于软件开发的高级编程语言,可以用于开发 Windows 应用程序、Web 应用程序、数据库应用程序等。
在本文中,将介绍一些常用的 VB 编程代码,帮助初学者快速入门和提高编程水平。
一、基本数据类型1. 整型数据在 VB 中,整型数据可以使用 Integer 类型表示,范围为 -32,768 到32,767。
定义整型变量的代码如下:```Dim num As Integernum = 10```2. 浮点数据浮点数据可以使用 Single 或 Double 类型表示,分别表示单精度浮点数和双精度浮点数。
定义浮点变量的代码如下:```Dim num As Singlenum = 3.143. 字符串数据字符串数据可以使用 String 类型表示,可以存储文本数据。
定义字符串变量的代码如下:```Dim str As Stringstr = "Hello, World!"```二、控制流程1. If...Then...Else 语句If...Then...Else 语句用于根据条件执行不同的代码块。
例如:```Dim num As Integernum = 10If num > 0 ThenMsgBox("Num is positive.")ElseMsgBox("Num is negative.")End If2. For 循环For 循环用于重复执行一段代码。
例如:```For i = 1 To 10MsgBox(i)Next i```3. Do While 循环Do While 循环在满足条件时执行代码块。
例如:```Dim i As Integeri = 1Do While i <= 10MsgBox(i)i = i + 1Loop```三、数组1. 一维数组一维数组在 VB 中用于存储相同类型的多个元素。
VB常见20道编程代码
哈哈哈20道编程代码1.1000以内的全部完数Private Sub Command1_Click()Dim n As IntegerDim i As IntegerDim s As LongFor n = 1 To 1000s = 1For i = 2 To n - 1If n Mod i = 0 Then s = s + iNext iIf s = n ThenText1 = Text1 & n & " "If k Mod 5 = 0 Then Text1 = Text1 & vbCrLfEnd IfNext nEnd SubPrivate Sub Command2_Click()EndEnd Sub2.百元买百鸡Private Sub Command1_Click()Dim i As IntegerDim j As IntegerFor i = 0 To 20For j = 0 To 33If 5 * i + 3 * j + (100 - i - j) * 1 / 3 = 100 ThenText1 = Text1 & "买" & CStr(i) & "只公鸡" & CStr(j) & "只母鸡" & CStr(100 - i - j) & "只小鸡"Text1 = Text1 & Chr(13) & Chr(10)End IfNext jNext iEnd SubPrivate Sub Command2_Click()EndEnd Sub3.不靠边元素和Private Sub Command1_Click()ClsRandomizeDim a(5, 5) As Integer, s%For i = 0 To 5For j = 0 To 5a(i, j) = Int(Rnd * 9)Print a(i, j) & ",";Sum = Sum + a(i, j)Next jPrintNext ik = SumSum = 0For i = 0 To 5Sum = Sum + a(i, 0) + a(i, 5) + a(0, i) + a(5, i) Next iSum = Sum - a(0, 0) - a(5, 0) - a(5, 5) - a(0, 5) Text1 = k - SumEnd SubPrivate Sub Command2_Click()EndEnd Sub4.递归函数求斐波拉契数列Option ExplicitPrivate Sub Command1_Click()Dim a1, a2, b As IntegerDim i, n As Integern = InputBox("显示数列的前N项")a1 = 1For i = 1 To nb = a1 + a2Text1.SelText = b & " "a1 = a2a2 = bNext iEnd SubPrivate Sub Command2_Click() EndEnd Sub5.各位数之和Private Sub Command1_Click() Dim i As StringDim j%Dim s%i = Text1For j = 1 To Len(i)st = Mid(i, j, 1)s = s + Val(st)Next jText2 = sEnd SubPrivate Sub Command2_Click() EndEnd Sub6.回文数Private Sub Command1_Click() Dim x$, y$, c$, i%x = Text1For i = 1 To Len(x)c = Mid(x, i, 1)y = c + yNext iIf y = x ThenText2 = "x是回文数"ElseText2 = "x不是回文数"End IfEnd Sub。
VB计算器源代码
Private Sub txtDisplay_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyNumpad0
cmdNumber_Click 0
Case vbKeyNumpad1
' 显示小数点
Private Sub cmdDecimal_Click()
If InStr(txtDisplay.Text, ".") Then
Beep
Else
If NewEntry Then
txtDisplay.Text = "."
NewEntry = False
Else
txtDisplay.Text = txtDisplay.Text & "."
End If
End If
End Sub
'计算上一操作符的运算结果
Private Sub cmdEquals_Click()
Case vbKeyBack, vbKeyDelete
DeleteCharacter
End Select
KeyCode = 0
End Sub
cmdNumber_Click 4
Case vbKeyNumpad5
cmdNumber_Click 5
Case vbKeyNumpad6
cmdNumber_Click 6
Case vbKeyNumpad7
Case vbKeySubtract
cmdOperator_Click opSubtract
VB简单计算器编程代码(附图)
课程设计说明书正文一、题目:计算器的创作和相应程序的编写二、本题的主要功能:通过计算器的创作熟悉各控件的属性和练习程序的编写。
三、程序截图:四、源程序清单:Begin VB.Form Form1Caption = "计算器"ClientHeight = 3765ClientLeft = 165ClientTop = 855ClientWidth = 5355Icon = "Form1.frx":0000LinkTopic = "Form1"LockControls = -1 'TrueScaleHeight = 3765ScaleWidth = 5355StartUpPosition = 3 '窗口缺省Begin mandButton Command4Caption = "="Height = 495Left = 4470TabIndex = 28Top = 3060Width = 735EndBegin mandButton Command3 Caption = "1/x"Height = 495Left = 4470TabIndex = 27Top = 2520Width = 735EndBegin mandButton Command2 Caption = "%"Height = 495Left = 4470TabIndex = 26Top = 1980Width = 735EndBegin mandButton Command1 Caption = "sqrt"Height = 495Left = 4470TabIndex = 25Top = 1440Width = 735EndBegin mandButton cmbDOT Caption = "."Height = 495Left = 2910TabIndex = 24Top = 3060Width = 735EndBegin mandButton cmbZF Caption = "+/-"Height = 495Left = 2130TabIndex = 23Top = 3060Width = 735 EndBegin mandButton cmbSign Caption = "+"Height = 495Index = 3Left = 3690TabIndex = 22Top = 3060Width = 735 EndBegin mandButton cmbSign Caption = "-"Height = 495Index = 2Left = 3690TabIndex = 21Top = 2520Width = 735 EndBegin mandButton cmbSign Caption = "*"Height = 495Index = 1Left = 3690TabIndex = 20Top = 1980Width = 735EndBegin mandButton cmbSign Caption = "/"Height = 495Index = 0Left = 3690TabIndex = 19Top = 1440Width = 735EndBegin mandButton cmbNUM Caption = "9"Height = 495Index = 9Left = 2910TabIndex = 18Top = 1440Width = 735EndBegin mandButton cmbNUM Caption = "8"Height = 495Index = 8Left = 2130TabIndex = 17Top = 1440Width = 735EndBegin mandButton cmbNUM Caption = "7"Height = 495Index = 7Left = 1350TabIndex = 16Width = 735EndBegin mandButton cmbNUM Caption = "6"Height = 495Index = 6Left = 2910TabIndex = 15Top = 1980Width = 735EndBegin mandButton cmbNUM Caption = "5"Height = 495Index = 5Left = 2130TabIndex = 14Top = 1980Width = 735EndBegin mandButton cmbNUM Caption = "4"Height = 495Index = 4Left = 1350TabIndex = 13Top = 1980Width = 735EndBegin mandButton cmbNUM Caption = "3"Height = 495Index = 3TabIndex = 12Top = 2520Width = 735EndBegin mandButton cmbNUM Caption = "2"Height = 495Index = 2Left = 2130TabIndex = 11Top = 2520Width = 735EndBegin mandButton cmbNUM Caption = "1"Height = 495Index = 1Left = 1350TabIndex = 10Top = 2520Width = 735EndBegin mandButton cmbNUM Caption = "0"Height = 495Index = 0Left = 1350TabIndex = 9Top = 3060Width = 735EndBegin mandButton cmbMa Caption = "M+"Left = 150TabIndex = 8Top = 3060Width = 975 EndBegin mandButton cmbMS Caption = "MS"Height = 495Left = 150TabIndex = 7Top = 2520Width = 975 EndBegin mandButton cmbMR Caption = "MR"Height = 495Left = 150TabIndex = 6Top = 1980Width = 975 EndBegin mandButton cmbMC Caption = "MC"Height = 495Left = 150TabIndex = 5Top = 1440Width = 975 EndBegin mandButton cmbC Caption = "C"Height = 495Left = 4020Top = 690Width = 1155EndBegin mandButton cmbCECaption = "CE"Height = 495Left = 2670TabIndex = 3Top = 690Width = 1155EndBegin mandButton cmbbackspace Caption = "Backspace"Height = 495Left = 1380TabIndex = 2Top = 690Width = 1155EndBegin VB.TextBox Text1Alignment = 1 'Right Justify Height = 375Left = 210TabIndex = 0Text = "0."Top = 120Width = 4935EndBegin bel Label2Alignment = 2 'CenterHeight = 255Left = 360TabIndex = 29Top = 840Width = 375EndBegin bel Label1Alignment = 2 'CenterBorderStyle = 1 'Fixed SingleBeginProperty FontName = "宋体"Size = 14.25Charset = 134Weight = 400Underline = 0 'FalseItalic = 0 'FalseStrikethrough = 0 'False EndPropertyHeight = 495Left = 240TabIndex = 1Top = 690Width = 615EndBegin VB.Menu editCaption = "编辑(&E)"EndBegin VB.Menu lookCaption = "查看(&V)"EndBegin VB.Menu helpCaption = "帮助(&H)"EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalseOption ExplicitPrivate Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long Dim dotflag As BooleanDim fuhao As StringDim first As DoubleDim second As DoubleDim isEqual As BooleanDim memory As Double '保存显示的数据Dim lianyong As Double '当连续按等号时使用该变量Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long Dim dotflag As BooleanDim fuhao As StringDim first As DoubleDim second As DoubleDim isEqual As BooleanDim memory As Double '保存显示的数据Dim lianyong As Double '当连续按等号时使用该变量Private Sub cmbDesign_Click(Index As Integer)End SubPrivate Sub cmbbackspace_Click()If Right(Trim(Text1.Text), 1) = "." ThenText1.Text = Mid(Text1.Text, 1, Len(Text1.Text) - 2) & "."ElseText1.Text = Mid(Text1.Text, 1, Len(Text1.Text) - 1)End IfIf Right(Text1.Text, 1) = "." Thendotflag = FalseEnd IfIf Len(Text1.Text) = 1 ThenText1.Text = "0."End IfEnd Sub 单击Backspace时删除文本框内最后一个字符Private Sub cmbC_Click()dotflag = FalseText1.Text = "0."first = 0second = 0End Sub 使文本框变成初始状态“0.”Private Sub cmbCE_Click()Text1.Text = "0."End Sub 删除文本框内的所有内容,使文本框变成初始状态“0.”Private Sub cmbDOT_Click()'标示点击了点“。
vb简单的计算机源代码
vb 简单的计算机源代码 .txt 如果青春的时光在闲散中度过,那么回忆岁月将是一场凄凉的悲剧。
杂草多的地方庄稼少,空话多的地方智慧少。
即使路上没有花朵,我仍可以欣赏荒芜。
Private Sub Command1_Click()Form1.Caption = " 欢迎使用智能计算器 "'载入默认正常显示If Check1.Value = "0" Then'1类分歧ElseIf Text1.Text = "" Or Text2.Text = "" Then'2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空 "ElseIf Text1.Text = "" And Text2.Text = "" Then'2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空 "Else'2类分歧Dim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a + bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" Then'1类分歧ElseIf Text1.Text = "" Or Text2.Text = "" Then'2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空 "ElseIf Text1.Text = "" And Text2.Text = "" Then'2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空 "Else'2类分歧Dim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d + eText3.Text = fEnd IfEnd SubPrivate Sub Command2_Click()Form1.Caption = " 欢迎使用智能计算器 "If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空 "ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d - eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a - bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub Command3_Click()Form1.Caption = "欢迎使用智能计算器" If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d * eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a * bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub Command4_Click()Form1.Caption = "欢迎使用智能计算器" If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空" ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "分数的分子不能为零" ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a / bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空" ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "分数的分子不能为零" ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d / eText3.Text = fEnd IfEnd SubPrivate Sub Command5_Click()Form1.Caption = "欢迎使用智能计算器" Text1.Text = ""Text2.Text = ""Text3.Text = ""End SubPrivate Sub Command6_Click()Form1.Caption = "欢迎使用智能计算器" Form1.HideForm3.ShowEnd SubPrivate Sub Command7_Click()EndEnd SubPrivate Sub Command8_Click()Form1.Caption = "欢迎使用智能计算器" If Text3.Text <> "" ThenText1.Text = Text3.TextText2.Text = ""Text3.Text = ""ElseForm1.Caption = "xataliq kuruldi"Text3.Text = "没有结果无法继续"End IfEnd SubPrivate Sub Text2_Change()End SubPrivate Sub乘_Click()Form1.Caption = "欢迎使用智能计算器" If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d * eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a * bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub除_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空" ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "分数的分子不能为零" ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a / bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空" ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "错误"Text3.Text = "分数的分子不能为零" ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d / eText3.Text = fEnd IfEnd SubPrivate Sub munasiwetlik_Click()Form1.Caption = "欢迎使用智能计算器" Form1.HideForm3.ShowEnd SubPrivate Sub继续 _Click()Form1.Caption = " 欢迎使用智能计算器" If Text3.Text <> "" ThenText1.Text = Text3.TextText2.Text = ""Text3.Text = ""ElseForm1.Caption = "xataliq"Text3.Text = "没有结果无法继续 "End IfEnd SubPrivate Sub加_Click()Form1.Caption = " 欢迎使用智能计算器" If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空 "ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a + bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d + eText3.Text = fEnd IfEnd SubPrivate Sub减_Click()Form1.Caption = "欢迎使用智能计算器" If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d - eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a - bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub清空_Click()Form1.Caption = "欢迎使用智能计算器" Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub----------------------------------------------form2 ?? ???? ??????Private Sub Command1_Click() Form3.HideForm1.ShowForm1.Text3.Text = ""End SubPrivate Sub Command2_Click() EndEnd Sub。
VB精典实用源代码(详细))
个人收藏的VB精典实用源代码。
若朋友您想要问如何才能学好vb,或者入门需要看什么教材一类的问题,建议你抱着一颗刻苦钻研的心去面对这门学问,多动脑,少提问,遇到不知道的,多查资料,多看看帖子,或者用断点来亲自试验。
实在不会了,请在此贴中查找您的常见问题,如果还没有,那请您发出新贴,向各位高手讨教:)查找方法:按ctrl+f,输入要查找的问题关键字即可每个问题中间用///分隔,这只是一部分最常见到的问题,以后会逐渐更新。
////////////////////////////////////////////////////////////////////////////////////如何用VB建立快捷方式Private Declare Function fCreateShellLink Lib "STKIT432.DLL" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As LongSub Command1_Click()Dim lReturn As Long'添加到桌面lReturn = fCreateShellLink("..\..\Desktop", "Shortcut to Calculator", "c:\windows\calc.exe", "")'添加到程序组lReturn = fCreateShellLink("", "Shortcut to Calculator", "c:\windows\calc.exe", "")'添加到启动组lReturn = fCreateShellLink("\Startup", "Shortcut to Calculator", "c:\windows\calc.exe", "")End Sub//////////////////////////////////////////////////////////////////////////////////// 如何让程序在Windows 启动时自动执行?有以下二个方法:方法1: 直接将快捷方式放到启动群组中。
vb简单的计算机源代码
vb简单的计算机源代码.txt如果青春的时光在闲散中度过,那么回忆岁月将是一场凄凉的悲剧。
杂草多的地方庄稼少,空话多的地方智慧少。
即使路上没有花朵,我仍可以欣赏荒芜。
Private Sub Command1_Click()Form1.Caption = "欢迎使用智能计算器" '载入默认正常显示If Check1.Value = "0" Then '1类分歧ElseIf Text1.Text = "" Or Text2.Text = "" Then '2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then '2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"Else '2类分歧Dim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a + bText3.Text = c页脚内容1Text1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" Then '1类分歧ElseIf Text1.Text = "" Or Text2.Text = "" Then '2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then '2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"Else '2类分歧Dim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d + eText3.Text = f页脚内容2End IfEnd SubPrivate Sub Command2_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d - e页脚内容3Text3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a - bText3.Text = cText1.Text = ""页脚内容4Text2.Text = ""End IfEnd SubPrivate Sub Command3_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)页脚内容5f = d * eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a * bText3.Text = cText1.Text = ""页脚内容6Text2.Text = ""End IfEnd SubPrivate Sub Command4_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "分数的分子不能为零"Else页脚内容7Dim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a / bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"页脚内容8Text3.Text = "分数的分子不能为零"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d / eText3.Text = fEnd IfEnd SubPrivate Sub Command5_Click()Form1.Caption = "欢迎使用智能计算器"Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub页脚内容9Private Sub Command6_Click()Form1.Caption = "欢迎使用智能计算器"Form1.HideForm3.ShowEnd SubPrivate Sub Command7_Click()EndEnd SubPrivate Sub Command8_Click()Form1.Caption = "欢迎使用智能计算器"If Text3.Text <> "" ThenText1.Text = Text3.TextText2.Text = ""Text3.Text = ""页脚内容10ElseForm1.Caption = "xataliq kuruldi"Text3.Text = "没有结果无法继续"End IfEnd SubPrivate Sub Text2_Change()End SubPrivate Sub 乘_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"页脚内容11Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d * eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Double页脚内容12a = Val(Text1.Text)b = Val(Text2.Text)c = a * bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub 除_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"页脚内容13Text3.Text = "运算数值不能为空"ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "分数的分子不能为零"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a / bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"页脚内容14ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "错误"Text3.Text = "分数的分子不能为零"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d / eText3.Text = fEnd IfEnd SubPrivate Sub munasiwetlik_Click()Form1.Caption = "欢迎使用智能计算器"页脚内容15Form1.HideForm3.ShowEnd SubPrivate Sub 继续_Click()Form1.Caption = "欢迎使用智能计算器"If Text3.Text <> "" ThenText1.Text = Text3.TextText2.Text = ""Text3.Text = ""ElseForm1.Caption = "xataliq"Text3.Text = "没有结果无法继续"End IfEnd SubPrivate Sub 加_Click()Form1.Caption = "欢迎使用智能计算器"页脚内容16If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a + bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" Then页脚内容17ElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d + eText3.Text = fEnd IfEnd SubPrivate Sub 减_Click()Form1.Caption = "欢迎使用智能计算器"页脚内容18If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d - eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "错误"页脚内容19Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a - bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub 清空_Click()Form1.Caption = "欢迎使用智能计算器"页脚内容20Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub----------------------------------------------form2 ?? ???? ??????Private Sub Command1_Click()Form3.HideForm1.ShowForm1.Text3.Text = ""End SubPrivate Sub Command2_Click()End页脚内容21End Sub页脚内容22。
用VB编写一个简单计算器
用VB编写一个简单计算器一、功能:实现简单的加减乘除功能,C归零,CE取消输入,%计算并显示第一个操作数的百分比。
二、控件:1个label,20个commandbutton。
三、计算器运行界面:四、详细代码:Option ExplicitDim Op1, Op2 '前面输入的操作数Dim DecimalFlag As Integer '小数点仍然存在吗?Dim NumOps As Integer '操作数个数Dim LastInput '指示上一次按键事件的类型Dim OpFlag '指示未完成的操作Dim TempReadout' C (取消) 按钮的Click 事件过程' 重新设置显示并初始化变量Private Sub Cancel_Click()Readout = Format(0, "0.")Op1 = 0Op2 = 0Form_LoadEnd Sub' CE (取消输入) 按钮的Click 事件过程Private Sub CancelEntry_Click()Readout = Format(0, "0.")DecimalFlag = FalseLastInput = "CE"End Sub' 小数点(.) 按钮的Click 事件过程' 如果上一次按键为运算符,初始化readout 为"0.";' 否则显示时追加一个小数点Private Sub Decimal_Click()If LastInput = "NEG" ThenReadout = Format(0, "-0.")ElseIf LastInput <> "NUMS" ThenReadout = Format(0, "0.")End IfDecimalFlag = TrueLastInput = "NUMS"End Sub' 窗体的初始化过程' 设置所有变量为其初始值Private Sub Form_Load()DecimalFlag = FalseNumOps = 0LastInput = "NONE"OpFlag = " "Readout = Format(0, "0.")'Decimal.Caption = Format(0, ".")End Sub' 数字键(0-9) 的Click 事件过程' 向显示中的数追加新数Private Sub Number_Click(Index As Integer)If LastInput <> "NUMS" ThenReadout = Format(0, ".")DecimalFlag = FalseEnd IfIf DecimalFlag ThenReadout = Readout + Number(Index).CaptionElseReadout = Left(Readout, InStr(Readout, Format(0, ".")) - 1) + Number(Index).Caption + Format(0, ".")End IfIf LastInput = "NEG" Then Readout = "-" & ReadoutLastInput = "NUMS"End Sub' 运算符(+, -, x, /, =) 的Click 事件过程' 如果接下来的按键是数字键,增加NumOps。
vb.net开发实例源代码
开发实例源代码
以下是一个简单的 开发实例源代码,用于创建一个 Windows 应用程序,显示一个带有按钮的窗口,当点击按钮时会弹出一个消息框。
```vb
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MessageBox.Show("你点击了按钮!")
End Sub
End Class
```
在这个示例中,我们创建了一个名为 `Form1` 的类,其中包含一个名为 `Button1` 的按钮和一个名为 `Button1_Click` 的事件处理程序。
当点击按钮时,`Button1_Click` 事件处理程序将执行,弹出一个消息框显示 "你点击了按钮!"。
这只是一个简单的示例,你可以根据自己的需求进行扩展和修改。
提供了丰富的工具和功能,帮助你创建各种类型的应用程序,包括 Windows 桌面应用程序、Web 应用程序、移动应用程序等。
如果你有特定的需求或想要进一步学习 开发,我建议你参考相关的教程、书籍或在线资源,以获取更详细和深入的信息。
VB计算器程序代码
VB计算器程序代码下面是一个简单的VB计算器程序代码,可以进行基本的四则运算:```VBImports System.MathPublic Class Form1Dim num1, num2, result As DoubleDim operatorType As String = ""Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.LoadEnd SubPrivate Sub Button_Click(sender As Object, e As EventArgs) Handles btn0.Click, btn1.Click, btn2.Click, btn3.Click,btn4.Click, btn5.Click, btn6.Click, btn7.Click, btn8.Click, btn9.Click, btnDot.ClickDim button As Button = CType(sender, Button)If button.Text = "." ThenIf Not txtDisplay.Text.Contains(".") ThentxtDisplay.Text += button.TextEnd IfElsetxtDisplay.Text += button.TextEnd IfEnd SubPrivate Sub Operator_Click(sender As Object, e As EventArgs) Handles btnAdd.Click, btnSubtract.Click, btnMultiply.Click, btnDivide.ClickDim button As Button = CType(sender, Button)num1 = CDbl(txtDisplay.Text)operatorType = button.TexttxtDisplay.ClearEnd SubPrivate Sub btnEquals_Click(sender As Object, e As EventArgs) Handles btnEquals.Clicknum2 = CDbl(txtDisplay.Text)Select Case operatorTypeCase "+"result = num1 + num2Case "-"result = num1 - num2Case "*"result = num1 * num2Case "/"If num2 <> 0 Thenresult = num1 / num2ElseMessageBox.Show("除数不能为零!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)End IfEnd SelecttxtDisplay.Text = result.ToStringEnd SubPrivate Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.ClicktxtDisplay.ClearEnd SubPrivate Sub btnSqrt_Click(sender As Object, e As EventArgs) Handles btnSqrt.ClickIf txtDisplay.Text = "" ThenMessageBox.Show("请输入一个数字!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)Elsenum1 = CDbl(txtDisplay.Text)result = Sqrt(num1)txtDisplay.Text = result.ToStringEnd IfEnd SubPrivate Sub btnPower_Click(sender As Object, e As EventArgs) Handles btnPower.ClickIf txtDisplay.Text = "" ThenMessageBox.Show("请输入一个数字!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)Elsenum1 = CDbl(txtDisplay.Text)result = num1 ^ 2txtDisplay.Text = result.ToStringEnd IfEnd SubPrivate Sub btnBackspace_Click(sender As Object, e As EventArgs) Handles btnBackspace.ClickIf txtDisplay.Text.Length > 0 ThentxtDisplay.Text = txtDisplay.Text.Substring(0, txtDisplay.Text.Length - 1)End IfEnd SubPrivate Sub btnNegative_Click(sender As Object, e As EventArgs) Handles btnNegative.ClickIf txtDisplay.Text.Length > 0 ThenIf txtDisplay.Text.Substring(0, 1) = "-" ThentxtDisplay.Text = txtDisplay.Text.Substring(1, txtDisplay.Text.Length - 1)ElsetxtDisplay.Text = "-" + txtDisplay.TextEnd IfEnd IfEnd SubEnd Class```这个计算器程序具有以下功能:1.支持0-9的数字输入和小数点的输入。
vb编程代码大全
vb编程代码大全VB(Visual Basic)是一种易于学习和使用的编程语言,广泛应用于Windows平台的软件开发。
VB编程通过编写和执行代码来实现任务,可以用于创建各种类型的应用程序,包括窗体应用程序、控制台应用程序、Web应用程序等。
本文将介绍一些常用的VB编程代码,帮助读者快速入门和掌握VB编程技巧。
一、VB基本语法在开始编写VB代码之前,我们先来了解一些基本的VB语法规则。
1. 注释VB中的注释用于解释代码的作用,不会被编译器执行。
注释可以是单行注释(以“'”开头)或多行注释(以“/*”开始,“*/”结束)。
示例:' 这是一个单行注释/*这是一个多行注释可以跨越多行*/2. 变量声明在VB中,变量需要先声明后使用。
变量的声明可以包括数据类型和变量名称。
示例:Dim x As Integer '声明一个整型变量x3. 变量赋值在VB中,可以使用赋值语句将一个值赋给变量。
示例:x = 10 '将变量x赋值为104. 运算符VB支持常见的运算符,包括算术运算符、比较运算符和逻辑运算符等。
示例:Dim a As Integer, b As Integera = 10b = 5Dim c As Integerc = a + b '加法运算c = a - b '减法运算c = a * b '乘法运算c = a / b '除法运算c = a Mod b '取余运算c = a > b '比较运算c = (a > 0) And (b > 0) '逻辑运算5. 控制结构VB中的控制结构包括条件语句和循环语句。
条件语句通过判断条件来选择不同的执行路径。
循环语句可以重复执行一段代码。
示例:If condition Then' 执行语句块1ElseIf condition2 Then' 执行语句块2Else' 执行语句块3End IfFor i = 1 To 10' 执行循环体Next i以上是VB的基本语法规则,通过掌握这些语法,可以编写简单的VB程序。
VB精典实用源代码(详细))
个人收藏的VB精典实用源代码。
若朋友您想要问如何才能学好vb,或者入门需要看什么教材一类的问题,建议你抱着一颗刻苦钻研的心去面对这门学问,多动脑,少提问,遇到不知道的,多查资料,多看看帖子,或者用断点来亲自试验。
实在不会了,请在此贴中查找您的常见问题,如果还没有,那请您发出新贴,向各位高手讨教:)查找方法:按ctrl+f,输入要查找的问题关键字即可每个问题中间用///分隔,这只是一部分最常见到的问题,以后会逐渐更新。
////////////////////////////////////////////////////////////////////////////////////如何用VB建立快捷方式Private Declare Function fCreateShellLink Lib "STKIT432.DLL" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As LongSub Command1_Click()Dim lReturn As Long'添加到桌面lReturn = fCreateShellLink("..\..\Desktop", "Shortcut to Calculator", "c:\windows\calc.exe", "")'添加到程序组lReturn = fCreateShellLink("", "Shortcut to Calculator", "c:\windows\calc.exe", "")'添加到启动组lReturn = fCreateShellLink("\Startup", "Shortcut to Calculator", "c:\windows\calc.exe", "")End Sub////////////////////////////////////////////////////////////////////////////////////如何让程序在Windows 启动时自动执行?有以下二个方法:方法1: 直接将快捷方式放到启动群组中。
vb简单的计算机源代码
vb 简单的计算机源代码 .txt 如果青春的时光在闲散中度过,那么回忆岁月将是一场凄凉的悲剧。
杂草多的地方庄稼少,空话多的地方智慧少。
即使路上没有花朵,我仍可以欣赏荒芜。
Private Sub Command1_Click()Form1.Caption = " 欢迎使用智能计算器 " ' 载入默认正常显示If Check1.Value = "0" Then '1 类分歧ElseIf Text1.Text = "" Or Text2.Text= "" Then '2 类分歧Form1.Caption = "xataliq kuruldi"Text3.Text= " 运算数值不能为空 "ElseIf Text1.Text = "" AndText2.Text = "" Then '2 类分歧Form1.Caption = "xataliq kuruldi"Text3.Text= " 运算数值不能为空 "Else '2 类分歧Dim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a + bText3.Text= cText1.Text= ""Text2.Text= ""End IfIf Check1.Value = "1" Then '1 类分歧ElseIf Text1.Text = "" Or Text2.Text= "" Then '2 类分歧Form1.Caption = "xataliq kuruldi"Text3.Text= " 运算数值不能为空 "ElseIf Text1.Text = "" AndText2.Text = "" Then '2 类分歧Form1.Caption = "xataliq kuruldi"--Text3.Text= " 运算数值不能为空 "Else '2 类分歧Dim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d + eText3.Text= fEnd IfEnd SubPrivate Sub Command2_Click()Form1.Caption = " 欢迎使用智能计算器 "If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text= "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text= " 运算数值不能为空 "ElseIf Text1.Text = "" And Text2.Text = "" Then--Form1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d - eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a - bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub Command3_Click()Form1.Caption = " 欢迎使用智能计算器" If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then--Form1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空" ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空" ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d * eText3.Text = fEnd If--If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a * bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub Command4_Click()Form1.Caption = " 欢迎使用智能计算器" If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 分数的分子不能为零" ElseDim a, b, c As Double--a = Val(Text1.Text)b = Val(Text2.Text)c = a / bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"--ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 分数的分子不能为零" ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d / eText3.Text = fEnd IfEnd SubPrivate Sub Command5_Click()Form1.Caption = " 欢迎使用智能计算器" Text1.Text = ""Text2.Text = ""Text3.Text = ""End SubPrivate Sub Command6_Click()Form1.Caption = " 欢迎使用智能计算器" Form1.HideForm3.ShowEnd SubPrivate Sub Command7_Click()End--End SubPrivate Sub Command8_Click()Form1.Caption = " 欢迎使用智能计算器" If Text3.Text <> "" ThenText1.Text = Text3.TextText2.Text = ""Text3.Text = ""ElseForm1.Caption = "xataliq kuruldi"Text3.Text = " 没有结果无法继续"--End IfEnd SubPrivate Sub Text2_Change()End SubPrivate Sub 乘_Click()Form1.Caption = " 欢迎使用智能计算器" If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d * eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)--b = Val(Text2.Text)c = a * bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub 除_Click()Form1.Caption = " 欢迎使用智能计算器"--If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空" ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空" ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 分数的分子不能为零" ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a / bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空" ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = " 错误 "Text3.Text = " 运算数值不能为空" ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = " 错误 "Text3.Text = " 分数的分子不能为零" ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d / eText3.Text = fEnd IfEnd SubPrivate Sub munasiwetlik_Click()Form1.Caption = " 欢迎使用智能计算器" Form1.HideForm3.ShowEnd SubPrivate Sub 继续 _Click()Form1.Caption = " 欢迎使用智能计算器" If Text3.Text <> "" ThenText1.Text = Text3.TextText2.Text= ""Text3.Text= ""ElseForm1.Caption = "xataliq"Text3.Text = " 没有结果无法继续"End IfEnd SubPrivate Sub 加_Click()Form1.Caption = " 欢迎使用智能计算器" If Check1.Value = "0" Then ElseIf Text1.Text = "" OrText2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = " 错误 "Text3.Text = " 运算数值不能为空" ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a + bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空" ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空" ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d + eText3.Text = fEnd IfEnd SubPrivate Sub 减_Click()Form1.Caption = " 欢迎使用智能计算器" If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = " 运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = " 错误 "Text3.Text = " 运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d - eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = " 错误 "Text3.Text = " 运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = " 错误 "Text3.Text = " 运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a - bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub 清空 _Click()Form1.Caption = " 欢迎使用智能计算器" Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub----------------------------------------------form2 ?? ???? ??????Private Sub Command1_Click() Form3.HideForm1.ShowForm1.Text3.Text = ""End SubPrivate Sub Command2_Click() EndEnd Sub。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Private Sub Command1_Click()Form1.Caption = "欢迎使用智能计算器" '载入默认正常显示If Check1.Value = "0" Then '1类分歧ElseIf Text1.Text = "" Or Text2.Text = "" Then '2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then '2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"Else '2类分歧Dim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a + bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" Then '1类分歧ElseIf Text1.Text = "" Or Text2.Text = "" Then '2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then '2类分歧Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"Else '2类分歧Dim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d + eText3.Text = fEnd IfEnd SubPrivate Sub Command2_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d - eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a - bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub Command3_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d * eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a * bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub Command4_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "分数的分子不能为零"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a / bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空" ElseIf Val(Text2.Text) = "0" Then Form1.Caption = "xataliq kuruldi" Text3.Text = "分数的分子不能为零" ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d / eText3.Text = fEnd IfEnd SubPrivate Sub Command5_Click()Form1.Caption = "欢迎使用智能计算器" Text1.Text = ""Text2.Text = ""Text3.Text = ""End SubPrivate Sub Command6_Click()Form1.Caption = "欢迎使用智能计算器" Form1.HideForm3.ShowEnd SubPrivate Sub Command7_Click()EndEnd SubPrivate Sub Command8_Click()Form1.Caption = "欢迎使用智能计算器" If Text3.Text <> "" ThenText1.Text = Text3.TextText2.Text = ""Text3.Text = ""ElseForm1.Caption = "xataliq kuruldi" Text3.Text = "没有结果无法继续"End IfEnd SubPrivate Sub Text2_Change()End SubPrivate Sub 乘_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d * eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a * bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub 除_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.Text = "分数的分子不能为零"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a / bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseIf Val(Text2.Text) = "0" ThenForm1.Caption = "错误"Text3.Text = "分数的分子不能为零"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d / eText3.Text = fEnd IfEnd SubPrivate Sub munasiwetlik_Click()Form1.Caption = "欢迎使用智能计算器"Form1.HideForm3.ShowEnd SubPrivate Sub 继续_Click()Form1.Caption = "欢迎使用智能计算器"If Text3.Text <> "" ThenText1.Text = Text3.TextText2.Text = ""Text3.Text = ""ElseForm1.Caption = "xataliq"Text3.Text = "没有结果无法继续"End IfEnd SubPrivate Sub 加_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a + bText3.Text = cText1.Text = ""Text2.Text = ""End IfIf Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d + eText3.Text = fEnd IfEnd SubPrivate Sub 减_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "xataliq kuruldi"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.Text)e = Val(Text2.Text)f = d - eText3.Text = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.Text = "" Or Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseIf Text1.Text = "" And Text2.Text = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.Text)b = Val(Text2.Text)c = a - bText3.Text = cText1.Text = ""Text2.Text = ""End IfEnd SubPrivate Sub 清空_Click()Form1.Caption = "欢迎使用智能计算器"Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub----------------------------------------------form2 ?? ???? ??????Private Sub Command1_Click() Form3.HideForm1.ShowForm1.Text3.Text = ""End SubPrivate Sub Command2_Click() EndEnd Sub。