问题:Dim counta As Double, countb As Double, countc As Double, ops As String, ops_single As StringPrivate Sub Command1_Click(Index As Integer)Text1.Text = Text1.Text + Command1(Index).CaptionEnd SubPrivate Sub Command2_Click(Index As Integer)counta = Val(Text1.Text)ops = Command2(Index).CaptionText1.Text = End SubPrivate Sub Command3_Click()countb = Val(Text1.Text)Select Case opsCase + Text1.Text = Str(counta + countb)Case - Text1.Text = Str(counta - countb)Case * Text1.Text = Str(counta * countb)Case / If countb = 0 Then MsgBox 除数不能为零, vbCritical, 出错 Text1.Text = Text1.SetFocus Else Text1.Text = Str(counta / countb) End IfEnd SelectEnd SubPrivate Sub Command4_Click()Dim strlen As Integerstrlen = Len(Text1.Text)Text1.Text = Left(Text1.Text, strlen - 1)End SubPrivate Sub Command5_Click()Text1.Text = counta = 0countb = 0Text1.SetFocusEnd SubPrivate Sub Command6_Click(Index As Integer)countc = Val(Text1.Text)ops_single = Command6(Index).CaptionSelect Case ops_singleCase sqrt If countc < 0 Then MsgBox 被开方数不能为负数, vbCritical, 出错 Text1.Text = Text1.SetFocus Else Text1.Text = Str(Sqr(countc)) End IfCase Abs Text1.Text = Str(Abs(countc))Case 1/x If countc = 0 Then MsgBox 被倒数不能为零, vbCritical, 出错 Text1.Text = Text1.SetFocus Else Text1.Text = Str(1 / countc) End IfCase % If countc < 0 Then MsgBox 被求百分数不能为零, vbCritical, 出错 Text1.Text = Text1.SetFocus Else Text1.Text = Str(countc * 100) End IfEnd SelectEnd SubPrivate Sub Form_Load()End SubPrivate Sub Text1_Change()End Sub邮箱:bestblack@126.com
要计算器阿,别写写这么多臭代码,我给你几行代码吧
Shell("calc.exe", AppWinStyle.NormalFocus, True, 2) 这是VB.NET的代码行,VB6页有这个函数SHELL的你自己找找资料吧,这个函数怎么用,我不记得VB6怎么写,都什么年代了,还用VB6 ,我的去看看,有问题给我留言 如果你对Dim counta As Double, countb As Double, countc As Double, ops As String, ops_single As StringPrivate Sub Command1_Click(Index As Integer)Text1.Text = Text1.Text + Command1(Index).CaptionEnd SubPrivate Sub Command2_Click(Index As Integer)counta = Val(Text1.Text)ops = Command2(Index).CaptionText1.Text = End SubPrivate Sub Command3_Click()countb = Val(Text1.Text)Select Case opsCase + Text1.Text = Str(counta + countb)Case - Text1.Text = Str(counta - countb)Case * Text1.Text = Str(counta * countb)Case / If countb = 0 Then MsgBox 除数不能为零, vbCritical, 出错 Text1.Text = Text1.SetFocus Else Text1.Text = Str(counta / countb) End IfEnd SelectEnd SubPrivate Sub Command4_Click()Dim strlen As Integerstrlen = Len(Text1.Text)Text1.Text = Left(Text1.Text, strlen - 1)End SubPrivate Sub Command5_Click()Text1.Text = counta = 0countb = 0Text1.SetFocusEnd SubPrivate Sub Command6_Click(Index As Integer)countc = Val(Text1.Text)ops_single = Command6(Index).CaptionSelect Case ops_singleCase sqrt If countc < 0 Then MsgBox 被开方数不能为负数, vbCritical, 出错 Text1.Text = Text1.SetFocus Else Text1.Text = Str(Sqr(countc)) End IfCase Abs Text1.Text = Str(Abs(countc))Case 1/x If countc = 0 Then MsgBox 被倒数不能为零, vbCritical, 出错 Text1.Text = Text1.SetFocus Else Text1.Text = Str(1 / countc) End IfCase % If countc < 0 Then MsgBox 被求百分数不能为零, vbCritical, 出错 Text1.Text = Text1.SetFocus Else Text1.Text = Str(countc * 100) End IfEnd SelectEnd SubPrivate Sub Form_Load()End SubPrivate Sub Text1_Change()End Sub邮箱:bestblack@126.com这个问题有好的意见或
建议,请留言
|