您当前的位置: 百科371电脑/网络VB → 电脑/网络内容 退出登录 用户管理 用户注册
本类热门文章
相关文章
中原建材网
有没有晓得这个代码怎样做计算器。(视频更好)

减小字体 增大字体

问题: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这个问题有好的意见或 建议,请留言
[] [返回上一页] [打 印]
电脑/网络评论 (评论内容只代表网友观点,与本站立场无关!)

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码

中原建材网 简单版 站长QQ:382546553