vb简单的计算机源代码
VB简单计算器编程代码(附图)
![VB简单计算器编程代码(附图)](https://img.taocdn.com/s3/m/9915993631b765ce05081456.png)
课程设计说明书正文一、题目:计算器的创作和相应程序的编写二、本题的主要功能:通过计算器的创作熟悉各控件的属性和练习程序的编写。
三、程序截图:四、源程序清单: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简易计算器代码](https://img.taocdn.com/s3/m/bb0e074d53ea551810a6f524ccbff121dd36c502.png)
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简易计算器代码](https://img.taocdn.com/s3/m/08255862dc36a32d7375a417866fb84ae45cc38f.png)
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常见20道编程代码
![VB常见20道编程代码](https://img.taocdn.com/s3/m/105e195dce84b9d528ea81c758f5f61fb736280c.png)
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 jPrivate 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 - Sum End 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 na2 = bNext iEnd SubPrivate Sub Command2_Click() EndEnd Sub5.各位数之和Private Sub Command1_Click() Dim i As String Dim 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 SubPrivate Sub Command2_Click()Private Sub Command3_Click()EndEnd Sub7.级数求和Private Sub Command1_Click() Dim i As Integer, t As Long, s As Singlei = 0: s = o: t = 1Dos = s + 1 / ti = i + 1t = t * iLoop Until 1 / t < 0.000001Text1 = sEnd SubPrivate Sub Command2_Click()EndEnd Sub8.矩阵的转置Option ExplicitOption Base 1Dim i As IntegerDim j As IntegerDim a() As IntegerDim n As IntegerPrivate Sub Command1_Click()Text3.SetFocusn = Val(Text3)ReDim a(n, n) '动态数组For i = 1 To nFor j = 1 To na(i, j) = Int(10 * Rnd + 0) '随机数Text1 = Text1 & a(i, j) & " " '⼀⾏Next jText1 = Text1 & Chr(13) & Chr(10) '多⾏Next iEnd Subn = Val(Text3)ReDim b(n, n)For i = 1 To nFor j = 1 To nb(i, j) = a(j, i) '转置Text2 = Text2 & b(i, j) & " " '⼀⾏Next jText2 = Text2 & Chr(13) & Chr(10) '多⾏Next i End SubPrivate Sub Command3_Click()Text1 = ""Text2 = ""Text3 = "" '清除Text3.SetFocusEnd SubPrivate Sub Command4_Click()End '结束End SubPrivate Sub Form_Load()Text1 = ""Text2 = ""Text3 = "" '清除End Sub9.靠边元素和Private Sub Command1_Click()ClsRandomizeDim a(5, 5) As IntegerFor i = 0 To 5For j = 0 To 5a(i, j) = Int(Rnd * 9)Print a(i, j) & ",";Sum = Sum + a(i, j)Next jSum = 0For i = 0 To 5Sum = Sum + a(i, 0) + a(i, 5) + a(0, i) + a(5, i)NextSum = Sum - a(0, 0) - a(5, 0) - a(5, 5) - a(0, 5)Text1 = SumEnd SubPrivate Sub Command2_Click()EndEnd Sub10.冒泡排序Option ExplicitOption Base 1Dim a(10) As IntegerDim i As IntegerPrivate Sub Command1_Click()For i = 1 To 10a(i) = Int(90 * Rnd + 10)Text1 = Text1 & Str(a(i)) & " "If i Mod 5 = 0 Then Text1 = Text1 & Chr(13) & Chr(10) Next i End SubPrivate Sub Command2_Click()Dim j As IntegerDim t As IntegerFor i = 1 To 9For j = 1 To 10 - iIf a(j) < a(j + 1) Thent = a(j)a(j) = a(j + 1)a(j + 1) = tEnd IfNext jNext iIf i Mod 5 = 0 Then Text2 = Text2 & Chr(13) & Chr(10) Next i End SubPrivate Sub Command3_Click()Text1 = ""Text2 = ""End SubPrivate Sub Command4_Click()EndEnd Sub11.逆序数Private Sub Command1_Click()Dim a As StringDim i%Dim s As Stringa = Text1For i = 1 To Len(a)st = Mid(a, i, 1)s = st + sNext iText2 = sEnd SubPrivate Sub Command2_Click()EndEnd Sub12.判断素数Private Sub Command1_Click()Dim n As IntegerDim i As Integern = Val(Text1)If n = 1 ThenMsgBox (CStr(n) & "是素数")ElseFor i = 2 To n - 1MsgBox (CStr(n) & "是素数")ElseMsgBox (CStr(n) & "不是素数") End IfEnd IfEnd SubPrivate Sub Command2_Click()Text1 = ""End SubPrivate Sub Command3_Click()EndEnd Sub13.求阶乘(递归)Private Function f(ByVal n As Long) As Long Dim i As Integer f = 1If n = 0 Or n = 1 Thenf = 1ElseFor i = 1 To nf = f * iNext iEnd IfEnd FunctionPrivate Sub Command1_Click()Dim n As Longn = Val(Text1)Text2 = f(n)End SubPrivate Sub Command2_Click()Text1 = ""Text2 = ""End SubPrivate Sub Command3_Click()Private Sub Command1_Click() Dim n%, i%, m%n = Val(Text1)For i = 1 To nIf i = 1 ThenPicture1.PrintElseIf n Mod i = 0 ThenFor m = 2 To i - 1If i Mod m = 0 Then Exit For Next mIf m = i ThenPicture1.Print i,End IfPicture1.PrintEnd IfEnd IfNext iEnd SubPrivate Sub Command2_Click() Text1 = ""Picture1.ClsEnd SubPrivate Sub Command3_Click() EndEnd Sub15.⽔仙花数Private Sub Command1_Click() Dim a, b, c As IntegerFor a = 0 To 9For b = 0 To 9For c = 1 To 9End IfNext cNext bNext aEnd SubPrivate Sub Command2_Click()EndEnd Sub16.顺序查找Option ExplicitOption Base 1Dim a(10) As IntegerDim i As IntegerPrivate Sub Command1_Click()For i = 1 To 10a(i) = Int(90 * Rnd + 10)Text1 = Text1 & Str(a(i))If i Mod 5 = 0 Then Text1 = Text1 & Chr(13) & Chr(10) Next i End SubPrivate Sub Command2_Click()Dim x As Integerx = Val(Text2)For i = 1 To 10If a(i) = x Then Exit ForNext iIf i <= 10 ThenText3 = Str(x) + "在第" + Str(i) + "个位置"ElseText3 = "没有找到"End IfEnd SubPrivate Sub Command3_Click()Text1 = ""Private Sub Command4_Click()EndEnd Sub17.随机10个整数最值,均值,和Dim i As Integer Dim a(10) As IntegerPrivate Sub Command1_Click() RandomizeFor i = 1 To 10a(i) = Int(90 * Rnd + 10) Next iFor i = 1 To 10Text1 = Text1 & a(i) & " " Next iEnd SubPrivate Sub Command2_Click() Dim k As Integer Dim l As IntegerDim s As Integerk = a(1)For i = 2 To 10If a(i) > k Then k = a(i)Next iText2 = kl = a(1)For i = 2 To 10If a(i) < l Then l = a(i)Next iText3 = ls = 0For i = 1 To 10s = s + a(i)Next iText5 = sText4 = s / 10End SubPrivate Sub Command3_Click() EndEnd SubPrivate Sub Form_Load()18.字符统计Private Sub Command1_Click()Dim s As String, i%, m As String, n% s = Text1 n = 0For i = 1 To Len(s)m = Mid(s, i, 1)If m >= "a" And m <= "z" Thenn = n + 1End IfNext iText2 = nEnd SubPrivate Sub Command2_Click()EndEnd Sub19.最⼤公约数Private Sub Command1_Click()Dim m As IntegerDim n As IntegerDim k As Integerm = Val(Text1)n = Val(Text2)Dok = m Mod nm = nn = kLoop Until k = 0Text3 = CStr(m)End SubPrivate Sub Command2_Click()Text1 = ""Text2 = ""Text3 = ""End SubPrivate Sub Command3_Click()EndEnd Sub20.最⼩公倍数Option ExplicitPrivate Sub Command1_Click() Dim m%, n%, k% Dim m1%, n1%Dim s%m = Val(Text1): n = Val(Text2) m1 = m: n1 = n Dok = m Mod nm = nn = kLoop Until k = 0s = m1 * n1 / mText3 = sEnd SubPrivate Sub Command2_Click() Text1 = ""Text2 = ""Text3 = ""End SubPrivate Sub Command3_Click() EndEnd Sub。
vb简单的计算机源代码
![vb简单的计算机源代码](https://img.taocdn.com/s3/m/a89d60cdcc22bcd126ff0cbc.png)
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简易计算器源码](https://img.taocdn.com/s3/m/9798492b590216fc700abb68a98271fe910eaf7a.png)
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程序代码(简单小程序)](https://img.taocdn.com/s3/m/30cb30100812a21614791711cc7931b765ce7b8c.png)
VB程序代码(简单小程序) Option Explicit
Private Sub btnCalculate_Click()
'按钮点击事件,计算两个数的和
'声明变量
Dim num1 As Double
Dim num2 As Double
Dim result As Double
'获取用户输入的数字
num1 = Val(txtNum1.Text)
num2 = Val(txtNum2.Text)
'计算和
result = num1 + num2
'将计算结果展示给用户
lblResult.Caption = "计算结果:" & result
End Sub
Private Sub Form_Load()
'窗体加载事件,初始化窗体
'设置窗体标题
Me.Caption = "简单计算器"
'设置标签的默认文本
lblNum1.Caption = "请输入第一个数:"
lblNum2.Caption = "请输入第二个数:"
lblResult.Caption = ""
如上所示,这是一个简单的VB程序,包含一个窗体和三个按钮,分别用于计算两个
数的和、清空所有输入框和标签的内容以及退出程序。
用户可以在两个文本框中输入数字,点击计算按钮后,程序会将两个数字相加并将结果展示给用户。
如果用户想重新计算,可
以点击清空按钮清除所有输入框和标签的内容,重新输入参数。
VB简易计算器代码
![VB简易计算器代码](https://img.taocdn.com/s3/m/bb53844602768e9951e73896.png)
这是一个简易计算器的VB代码,下面是这个计算器的界面,有一个文本输入框和16个按钮Public Class Form1Dim OperatorState As IntegerDim data1 As IntegerDim result As IntegerDim data2 As Integer’下面是0~9十个按钮的点击事件Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickTextBox1.Text = TextBox1.Text + "1"End SubPrivate Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.ClickTextBox1.Text = TextBox1.Text + "2"End SubPrivate Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.ClickTextBox1.Text = TextBox1.Text + "3"End SubPrivate Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.ClickTextBox1.Text = TextBox1.Text + "4"End SubPrivate Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.ClickTextBox1.Text = TextBox1.Text + "5"End SubPrivate Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.ClickTextBox1.Text = TextBox1.Text + "6"End SubPrivate Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.ClickTextBox1.Text = TextBox1.Text + "7"End SubPrivate Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.ClickTextBox1.Text = TextBox1.Text + "8"End SubPrivate Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.ClickTextBox1.Text = TextBox1.Text + "9"End SubPrivate Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.ClickTextBox1.Text = TextBox1.Text + "0"End Sub’下面是清除键的代码Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.ClickTextBox1.Text = ""End Sub’下面是加减乘除四个按钮的代码Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Clickdata1 = Val(TextBox1.Text)OperatorState = 1TextBox1.Text = ""End SubPrivate Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button12.Clickdata1 = Val(TextBox1.Text)OperatorState = 2TextBox1.Text = ""End SubPrivate Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Clickdata1 = Val(TextBox1.Text)OperatorState = 3TextBox1.Text = ""End SubPrivate Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Clickdata1 = Val(TextBox1.Text)OperatorState = 4TextBox1.Text = ""End Sub’下面是等于号的的代码Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Clickdata2 = Val(TextBox1.Text)If (OperatorState = 1) Thenresult = data1 + data2End IfIf (OperatorState = 2) Thenresult = data1 - data2End IfIf (OperatorState = 3) Thenresult = data1 * data2End IfIf (OperatorState = 4) Thenresult = data1 / data2End IfTextBox1.Text = Str(result)End SubEnd Class。
VB简单计算器编程代码(附图)
![VB简单计算器编程代码(附图)](https://img.taocdn.com/s3/m/69e7f1d484254b35eefd34eb.png)
课程设计说明书正文一、题目:计算器的创作和相应程序的编写二、本题的主要功能:通过计算器的创作熟悉各控件的属性和练习程序的编写。
三、程序截图:四、源程序清单: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简单的计算机源代码](https://img.taocdn.com/s3/m/e1005a2514791711cc791743.png)
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精典实用源代码(详细))](https://img.taocdn.com/s3/m/a1816f39f524ccbff021843c.png)
个人收藏的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简单的计算机源代码](https://img.taocdn.com/s3/m/eae68349fad6195f312ba663.png)
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计算器 源代码](https://img.taocdn.com/s3/m/2b07b9e5856a561252d36f29.png)
源代码:PublicClass CalculatorDim flag AsBoolean = FalseDim firstNum AsDouble = 0 '第一个操作数Dim secondNum AsDouble = 0 '第二个操作数Dim result AsDouble = 0 '计算结果Dim sign AsChar'符号PrivateSub Button0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button0.ClickIf flag = FalseThenTextBox.Text = "0"flag = TrueElseTextBox.Text = TextBox.Text + "0"EndIfPrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickIf flag = FalseThenTextBox.Text = "1"flag = TrueElseTextBox.Text = TextBox.Text + "1"EndIfEndSubPrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.ClickIf flag = FalseThenTextBox.Text = "2"flag = TrueElseTextBox.Text = TextBox.Text + "2"EndIfEndSubPrivateSub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.ClickIf flag = FalseThenTextBox.Text = "3"flag = TrueElseTextBox.Text = TextBox.Text + "3"EndIfEndSubPrivateSub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.ClickIf flag = FalseThenTextBox.Text = "4"flag = TrueTextBox.Text = TextBox.Text + "4"EndIfEndSubPrivateSub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.ClickIf flag = FalseThenTextBox.Text = "5"flag = TrueElseTextBox.Text = TextBox.Text + "5"EndIfEndSubPrivateSub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.ClickIf flag = FalseThenTextBox.Text = "6"flag = TrueElseTextBox.Text = TextBox.Text + "6"EndIfEndSubPrivateSub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.ClickIf flag = FalseThenTextBox.Text = "7"flag = TrueElseTextBox.Text = TextBox.Text + "7"EndIfEndSubPrivateSub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.ClickIf flag = FalseThenTextBox.Text = "8"flag = TrueElseTextBox.Text = TextBox.Text + "8"EndIfEndSubPrivateSub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.ClickIf flag = FalseThenTextBox.Text = "9"flag = TrueElseTextBox.Text = TextBox.Text + "9"EndIfEndSubPrivateSub Point_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Point.ClickTextBox.Text = TextBox.Text + "."EndSubPrivateSub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.Click '加号sign = "+"firstNum = Convert.ToDouble(TextBox.Text)flag = FalseEndSubPrivateSub Sub1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sub1.Click '减号sign = "-"firstNum = Convert.ToDouble(TextBox.Text)flag = FalseEndSubPrivateSub Mul_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles Mul.Click '乘号sign = "*"firstNum = Convert.ToDouble(TextBox.Text)flag = FalseEndSubPrivateSub Div_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Div.Click '除号sign = "/"firstNum = Convert.ToDouble(TextBox.Text)flag = FalseEndSubPrivateSub Equal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Equal.Click '等号SelectCase signCase"+"secondNum = Convert.ToDouble(TextBox.Text) result = firstNum + secondNumTextBox.Text = resultCase"-"secondNum = Convert.ToDouble(TextBox.Text) result = firstNum - secondNumTextBox.Text = resultCase"*"secondNum = Convert.ToDouble(TextBox.Text) result = firstNum * secondNumTextBox.Text = resultCase"/"secondNum = Convert.ToDouble(TextBox.Text) result = firstNum / secondNumTextBox.Text = resultEndSelectflag = FalseEndSubEndClass说明:为了便于理解,已对部分按钮的名称改名,稍作修改就能运行。
VB计算器程序代码
![VB计算器程序代码](https://img.taocdn.com/s3/m/3d96e521cbaedd3383c4bb4cf7ec4afe04a1b105.png)
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源代码](https://img.taocdn.com/s3/m/86a5a562caaedd3383c4d326.png)
第3章课前体验Private Sub Form_Click()For i = 1 To 10For j = 1 To iPrint "* ";Next jPrintNext iEnd Sub【例3-1】Private Sub Form_Click()c1$ = Chr$(13) + Chr$(10)msg1$ = "请输入您的名字: "msg2$ = "输入后按回车键"msg3$ = "或单击“确定”按钮"msg$ = msg1$ + c1$ + msg2$ + c1$ + msg3$name$ = InputBox(msg$, "InputBox 函数示例", "张三")Print name$End Sub【例3-2】Private Sub Form_Click()Msg1$=”Are you Continue to?”msg2$=”Operation Dialog Box”r=MsgBox(msg1$,34,msg2$)Print rEnd Sub【例3-3】编写程序,用MsgBox函数判断是否继续执行。
Private Sub Form_Click()msg$ = "请确认此数据是否正确"Title$ = "数据检查对话框"x = MsgBox(msg$, 19, Title$)If x = 6 ThenPrint x * xElseIf x = 7 ThenPrint "请重新输入"End IfEnd Sub【例3-5】Private Sub Form_Click()Print: PrintFontName = "隶书"FontSize = 16Print " 姓名"; Tab(8); "年龄"; Tab(16); "职务";Print Tab(24); "单位"; Tab(32); "籍贯"PrintPrint "吴大明"; Tab(8); 25; Tab(16); "职员"; Tab(24); "人事科"; Tab(32); "北京"Print "吴大明"; Tab(8); 25; Tab(16); "职员"; Tab(24); "人事科"; Tab(32); "北京"End Sub【例3-6】Private Sub Form_Click()X = InputBox("请输入成绩", "学生成绩录入", "00")Print xEnd Sub【例3-7】Private Sub Form_Click()Dim x As Single, y As Singlex=InputBox(“请输入x的值”)If x>0 Then y=1 ElseIf x=0 Then y=0 Else y=-1Print “x=”; x ,”y=” ; yEnd Sub【例3-8】Private Sub Form_Click()Dim msg, UserInputmsg = "请输入一个字母或0~9之间的数字."UserInput = InputBox(msg) ‘输入一个字母或数字If Not IsNumeric(UserInput) Then ‘判断是否是数字If Len(UserInput) = 1 Then ‘不是数字时,判断输入的字符串长度是否为1 Select Case Asc(UserInput) ‘判断输入字母的ASCII码值Case 60 To 90 '在60-90之间为大写字母msg = "你输入的是一个大写字母'"msg = msg & Chr(Asc(UserInput)) & "'。
VB精典实用源代码(详细))
![VB精典实用源代码(详细))](https://img.taocdn.com/s3/m/513af648ad02de80d4d8408d.png)
个人收藏的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简单的计算机源代码](https://img.taocdn.com/s3/m/2c08a3c37c1cfad6185fa710.png)
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。
VB简易计算器代码
![VB简易计算器代码](https://img.taocdn.com/s3/m/ffa95fa5192e45361166f513.png)
Public Class Form1Dim OperatorState As IntegerDim data1 As IntegerDim result As IntegerDim data2 As Integer’下面是0~9十个按钮的点击事件Private Sub Button1_Click(ByVal sender As , ByVal e As Handles = + "1"End SubPrivate Sub Button2_Click(ByVal sender As , ByVal e As Handles = + "2"End SubPrivate Sub Button3_Click(ByVal sender As , ByVal e As Handles = + "3"End SubPrivate Sub Button4_Click(ByVal sender As , ByVal e As Handles = + "4"End SubPrivate Sub Button5_Click(ByVal sender As , ByVal e As Handles = + "5"End SubPrivate Sub Button6_Click(ByVal sender As , ByVal e As Handles = + "6"End SubPrivate Sub Button7_Click(ByVal sender As , ByVal e As Handles = + "7"End SubPrivate Sub Button8_Click(ByVal sender As , ByVal e As Handles = + "8"End SubPrivate Sub Button9_Click(ByVal sender As , ByVal e As Handles = + "9"End SubPrivate Sub Button10_Click(ByVal sender As , ByVal e As Handles = + "0"End Sub’下面是清除键的代码Private Sub Button15_Click(ByVal sender As , ByVal e As Handles = ""End Sub’下面是加减乘除四个按钮的代码Private Sub Button11_Click(ByVal sender As , ByVal e As Handles data1 = ValOperatorState = 1= ""End SubPrivate Sub Button12_Click(ByVal sender As , ByVal e As Handlesdata1 = ValOperatorState = 2= ""End SubPrivate Sub Button13_Click(ByVal sender As , ByVal e As Handles data1 = ValOperatorState = 3= ""End SubPrivate Sub Button14_Click(ByVal sender As , ByVal e As Handles data1 = ValOperatorState = 4= ""End Sub’下面是等于号的的代码Private Sub Button16_Click(ByVal sender As , ByVal e As Handlesdata2 = ValIf (OperatorState = 1) Thenresult = data1 + data2End IfIf (OperatorState = 2) Thenresult = data1 - data2End IfIf (OperatorState = 3) Thenresult = data1 * data2End IfIf (OperatorState = 4) Then result = data1 / data2End If= Str(result)End SubEnd Class。
VB计算器源代码
![VB计算器源代码](https://img.taocdn.com/s3/m/e35882b7294ac850ad02de80d4d8d15abe2300e4.png)
VB计算器源代码Private Data As DoublePrivate lOperation As LongPrivate fClear As BooleanPrivate Sub Command1_Click(Index As Integer)If fClear = True Then Text1.Text = "": fClear = FalseText1.Text = Text1.Text & IndexEnd SubPrivate Sub Command2_Click()If InStr(1, Text1.Text, ".") <= 0 Then Text1.Text = Text1.Text & "."End SubPrivate Sub Command3_Click()If fClear = False ThenSelect Case lOperationCase 0Case 1: Text1.Text = Data + Val(Text1.Text)Case 2: Text1.Text = Data - Val(Text1.T ext)Case 3: Text1.Text = Data * Val(Text1.Text)Case 4: If Val(Text1.Text) = 0 Then MsgBox "除数不等于0": Exit Sub Else Text1.T ext = Data / Val(Text1.T ext)End SelectEnd IfData = Val(Text1.Text)fClear = TruelOperation = 0End SubPrivate Sub Command4_Click()If Len(Text1.T ext) > 0 Then Text1.Text = Left(T ext1.Text, Len(Text1.Text) - 1)End SubPrivate Sub Command5_Click()If fClear = False ThenSelect Case lOperationCase 0Case 1: Text1.Text = Data + Val(Text1.Text)Case 2: Text1.Text = Data - Val(Text1.T ext)Case 3: Text1.Text = Data * Val(Text1.Text)Case 4: If Val(Text1.Text) = 0 Then MsgBox "除数不等于0": Exit Sub Else Text1.T ext = Data / Val(Text1.T ext)End SelectEnd IfData = Val(Text1.Text)fClear = TruelOperation = 1End SubPrivate Sub Command6_Click()If fClear = False ThenSelect Case lOperationCase 0Case 1: Text1.Text = Data + Val(Text1.Text)Case 2: Text1.Text = Data - Val(Text1.T ext)Case 3: Text1.Text = Data * Val(Text1.Text)Case 4: If Val(Text1.Text) = 0 Then MsgBox "除数不等于0": Exit Sub Else Text1.T ext = Data / Val(Text1.T ext)End SelectEnd IfData = Val(Text1.Text)fClear = TruelOperation = 2End SubPrivate Sub Command7_Click()If fClear = False ThenSelect Case lOperationCase 0Case 1: Text1.Text = Data + Val(Text1.Text)Case 2: Text1.Text = Data - Val(Text1.T ext)Case 3: Text1.Text = Data * Val(Text1.Text)Case 4: If Val(Text1.Text) = 0 Then MsgBox "除数不等于0": Exit Sub Else Text1.T ext = Data / Val(Text1.T ext)End SelectEnd IfData = Val(Text1.Text)fClear = TruelOperation = 3End SubPrivate Sub Command8_Click()If fClear = False ThenSelect Case lOperationCase 0Case 1: Text1.Text = Data + Val(Text1.Text)Case 2: Text1.Text = Data - Val(Text1.T ext)Case 3: Text1.Text = Data * Val(Text1.Text)Case 4: If Val(Text1.Text) = 0 Then MsgBox "除数不等于0": Exit Sub Else Text1.T ext = Data / Val(Text1.T ext)End SelectEnd IfData = Val(Text1.Text)fClear = TruelOperation = 4End SubPrivate Sub Command9_Click()Text1.Text = ""lOperation = 0End Sub。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
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。