急求一个VB课程设计计算器的完整代码,最好有个人做好了给我,万分感谢
3个回答
2011-06-20
展开全部
什么叫做“课程设计计算器”?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
将以下这段代码保存为 .frm 的文件,然后用VB打开,执行即可。如果有问题,请点击VB里面的工具栏-工程-引用-在“Microsoft Script Control 1.0”前面打勾,点确定。
VERSION 5.00
Begin VB.Form Form1
Caption = "模拟计算器"
ClientHeight = 2820
ClientLeft = 60
ClientTop = 450
ClientWidth = 3975
LinkTopic = "Form1"
ScaleHeight = 2820
ScaleWidth = 3975
StartUpPosition = 3 '窗口缺省
Begin VB.ListBox List1
Height = 1140
ItemData = "jisuan.frx":0000
Left = 240
List = "jisuan.frx":0002
TabIndex = 4
Top = 1440
Width = 3495
End
Begin VB.TextBox Text1
Height = 390
Left = 840
TabIndex = 3
Top = 120
Width = 2895
End
Begin VB.CommandButton Command3
Caption = "清空结果"
Height = 375
Left = 2760
TabIndex = 2
Top = 720
Width = 975
End
Begin VB.CommandButton Command2
Caption = "重新输入"
Height = 375
Left = 1440
TabIndex = 1
Top = 720
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "计算"
Height = 375
Left = 240
TabIndex = 0
Top = 720
Width = 975
End
Begin VB.Label Label2
Caption = "计算结果:"
Height = 255
Left = 240
TabIndex = 6
Top = 1200
Width = 1095
End
Begin VB.Label Label1
Caption = "输入"
Height = 255
Left = 240
TabIndex = 5
Top = 240
Width = 495
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Const Setstring = "0.123456789/*-+^\()<>qwertyuioplkjhfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM"
Private Sub Form_Load()
Show
Text1.SetFocus
End Sub
Private Sub Command1_Click()
Dim st As String, sc As String, s As Long, tmp As String, i As Integer, j As Integer, tt As String
sc = Text1.Text
tmp = Space(Len(Text1.Text))
For i = 1 To Len(sc)
tt = Mid(sc, i, 1)
Select Case Asc(tt)
Case 0
Case 13
Case 32
Case 10
Case Else
j = j + 1
Mid(tmp, j, 1) = tt
End Select
Next
sc = Left(tmp, j)
s = InStr(sc, "=")
If s Then sc = Left(sc, s - 1)
s = InStr(sc, Chr(13))
If s Then
sc = Left(sc, s - 1)
s = 0
End If
On Error GoTo E:
Dim ScriptControl1 As New ScriptControl
'Dim strVBS As String
ScriptControl1.Language = "VBScript"
Dim strCode As String
strCode = "function DivideByZero()" & vbCrLf & _
"DivideByZero=(" & sc & ")" & vbCrLf & _
"End function"
' If InStr(Text1.Text, "=") Then GoTo E:
'Text1.Text = strCode
With ScriptControl1
.AddCode strCode
st = .Run("DivideByZero")
End With
Text1.Text = sc & "=" & st
List1.AddItem Text1.Text
Text1.SelLength = Len(Text1.Text)
Exit Sub
E:
Text1.Text = sc & "=ERROR"
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
List1.Clear
End Sub
Private Sub List1_Click()
Text1.Text = List1.Text
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Call Command1_Click
End Sub
VERSION 5.00
Begin VB.Form Form1
Caption = "模拟计算器"
ClientHeight = 2820
ClientLeft = 60
ClientTop = 450
ClientWidth = 3975
LinkTopic = "Form1"
ScaleHeight = 2820
ScaleWidth = 3975
StartUpPosition = 3 '窗口缺省
Begin VB.ListBox List1
Height = 1140
ItemData = "jisuan.frx":0000
Left = 240
List = "jisuan.frx":0002
TabIndex = 4
Top = 1440
Width = 3495
End
Begin VB.TextBox Text1
Height = 390
Left = 840
TabIndex = 3
Top = 120
Width = 2895
End
Begin VB.CommandButton Command3
Caption = "清空结果"
Height = 375
Left = 2760
TabIndex = 2
Top = 720
Width = 975
End
Begin VB.CommandButton Command2
Caption = "重新输入"
Height = 375
Left = 1440
TabIndex = 1
Top = 720
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "计算"
Height = 375
Left = 240
TabIndex = 0
Top = 720
Width = 975
End
Begin VB.Label Label2
Caption = "计算结果:"
Height = 255
Left = 240
TabIndex = 6
Top = 1200
Width = 1095
End
Begin VB.Label Label1
Caption = "输入"
Height = 255
Left = 240
TabIndex = 5
Top = 240
Width = 495
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Const Setstring = "0.123456789/*-+^\()<>qwertyuioplkjhfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM"
Private Sub Form_Load()
Show
Text1.SetFocus
End Sub
Private Sub Command1_Click()
Dim st As String, sc As String, s As Long, tmp As String, i As Integer, j As Integer, tt As String
sc = Text1.Text
tmp = Space(Len(Text1.Text))
For i = 1 To Len(sc)
tt = Mid(sc, i, 1)
Select Case Asc(tt)
Case 0
Case 13
Case 32
Case 10
Case Else
j = j + 1
Mid(tmp, j, 1) = tt
End Select
Next
sc = Left(tmp, j)
s = InStr(sc, "=")
If s Then sc = Left(sc, s - 1)
s = InStr(sc, Chr(13))
If s Then
sc = Left(sc, s - 1)
s = 0
End If
On Error GoTo E:
Dim ScriptControl1 As New ScriptControl
'Dim strVBS As String
ScriptControl1.Language = "VBScript"
Dim strCode As String
strCode = "function DivideByZero()" & vbCrLf & _
"DivideByZero=(" & sc & ")" & vbCrLf & _
"End function"
' If InStr(Text1.Text, "=") Then GoTo E:
'Text1.Text = strCode
With ScriptControl1
.AddCode strCode
st = .Run("DivideByZero")
End With
Text1.Text = sc & "=" & st
List1.AddItem Text1.Text
Text1.SelLength = Len(Text1.Text)
Exit Sub
E:
Text1.Text = sc & "=ERROR"
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
List1.Clear
End Sub
Private Sub List1_Click()
Text1.Text = List1.Text
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Call Command1_Click
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
邮箱地址:
给你发源文件!~~~~~~~~~~~
给你发源文件!~~~~~~~~~~~
追问
我的QQ邮箱632988304@qq。com,额我还没收到
追答
已发送...
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询