我刚学VB!教程里要我编一个加减运算的程序,我不懂,请哪位高手指点指点!谢谢!

解决方案 »

  1.   

    说详细一点:
    dim i,j as integer
    i=5
    j=8
    msgbox i+j
    最简单的加法
      

  2.   

    我现在只学到VB的对象及其操作,还没接触到语言!它让我任意输入两个数,按命令按钮“相加”得到两数之和,按“相减”得到两数之差!还有设置的控件属性,主要是针对窗体,命令按钮和标签的Caption属性,文本框的Text属性和Font属性进行设置!
        我现在就是不知道对那两个按钮的Click事件过程怎么编写代码!
      

  3.   

    建议还是先看看书吧
    你的这些问题书中都有说明的
    属性问题可以查msdn,比我们说的详细很多:)
    两个变量,加,减
    这是如此
    试试看^_^
      

  4.   

    把下面的代码粘到记事本中,保存为 Form1.frm。自己创建一个工程,删除原来的 Form1,把这个窗体添加进去。VERSION 5.00
    Begin VB.Form Form1 
       Caption         =   "Form1"
       ClientHeight    =   3195
       ClientLeft      =   60
       ClientTop       =   345
       ClientWidth     =   4680
       LinkTopic       =   "Form1"
       ScaleHeight     =   3195
       ScaleWidth      =   4680
       StartUpPosition =   3  '窗口缺省
       Begin VB.TextBox Text2 
          Height          =   270
          Left            =   1920
          TabIndex        =   3
          Top             =   960
          Width           =   1335
       End
       Begin VB.TextBox Text1 
          Height          =   270
          Left            =   1920
          TabIndex        =   2
          Top             =   360
          Width           =   1335
       End
       Begin VB.CommandButton Command2 
          Caption         =   "-"
          Height          =   615
          Left            =   2520
          TabIndex        =   1
          Top             =   2280
          Width           =   1695
       End
       Begin VB.CommandButton Command1 
          Caption         =   "+"
          Height          =   615
          Left            =   480
          TabIndex        =   0
          Top             =   2280
          Width           =   1695
       End
       Begin VB.Label Label3 
          BackColor       =   &H80000009&
          BorderStyle     =   1  'Fixed Single
          Height          =   255
          Left            =   1920
          TabIndex        =   6
          Top             =   1560
          Width           =   1335
       End
       Begin VB.Label Label2 
          Caption         =   "数字 2:"
          Height          =   255
          Left            =   840
          TabIndex        =   5
          Top             =   960
          Width           =   735
       End
       Begin VB.Label Label1 
          Caption         =   "数字 1:"
          Height          =   255
          Left            =   840
          TabIndex        =   4
          Top             =   360
          Width           =   735
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Option ExplicitPrivate Sub Command1_Click()
        Label3.Caption = "=" & (Val(Text1) + Val(Text2))
    End SubPrivate Sub Command2_Click()
        Label3.Caption = "=" & (Val(Text1) - Val(Text2))
    End Sub
      

  5.   

    3个textbox 两个command  
    text3.text=val(text1.text)+val(text2.text) command1 是加法
    text3.text=val(text1.text)-val(text2.text) command2 是减法
      

  6.   

    套用红楼梦的话 早知道如此 何必趟这趟混水
    用+ - * / Mod ()反正就是和列数学表达式似的 把变量连接起来就OK了