回复: 请问一道简单的VB题……
原帖由 helenzhu 于 2007-9-25 23:58:00 发表 a = Text1.Text 就有错误……
|
我剛剛做的... 你就自己看著照做一次吧...
======
上傳不了JPG... 才113KB也說太大了... :(
以下是Form1.frm的內容 (可以用Notepad開啟)...
======
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Left = 2400
TabIndex = 4
Top = 600
Width = 1335
End
Begin VB.TextBox Text4
Height = 375
Left = 50
TabIndex = 3
Text = "0"
Top = 2040
Width = 2000
End
Begin VB.TextBox Text3
Height = 375
Left = 50
TabIndex = 2
Text = "0"
Top = 1440
Width = 2000
End
Begin VB.TextBox Text2
Height = 375
Left = 50
TabIndex = 1
Text = "0"
Top = 840
Width = 2000
End
Begin VB.TextBox Text1
Height = 375
Left = 50
TabIndex = 0
Text = "0"
Top = 360
Width = 2000
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim a As Single, b As Single, c As Single, d As Single
Private Sub Command1_Click()
If (Len(Text1.Text) > 0) Then
a = CSng(Text1.Text)
Else
Text1.Text = "0"
a = 0
End If
If (Len(Text2.Text) > 0) Then
b = CSng(Text2.Text)
Else
Textb.Text = "0"
b = 0
End If
If (Len(Text3.Text) > 0) Then
c = CSng(Text3.Text)
Else
Text3.Text = "0"
c = 0
End If
d = (a + b + c) / 3
Text4.Text = d
End Sub
cheong00 最后编辑于 2007-09-26 00:18:06