17年10个月前IP:未同步
80262
4楼
写程序注意一下格式,这样方便阅读,也方便查错。

Private Sub CmdSolve_Click()
    
Dim a As Single, b As Single, c As Single, p As Single
    Dim
x1 As Single, X2 As Single, e As Single, f As Single
    
a = Val(txtA.Text)
    b = Val(txtB.Text)
    c = Val(txtC.Text)
    p = b ^
2 - 4 * a * c
    
    
If a = 0 Then
        
txtRoot1.Text = "无解"
        
txtRoot2.Text = "无解"
    
Else
         If
p >= 0 Then
            
x1 = (-b + Sqr(p)) / (2 * a)
            X2 = (-b - Sqr(p)) / (
2 * a)
            txtRoot1.Text = x1
            txtRoot2.Text = X2
        
Else
            
e = -b / (2 * a)
            f = (Sqr(-p)) / (
2 * a)
            txtRoot1.Text = Str(e) &
"+" & Str(f) & "i"
            
txtRoot2.Text = Str(e) & "+" & Str(f) & "i"
        
End If
    End If
End Sub
评论
文号 / 80262

千古风流
名片发私信
学术分 2
总主题 14 帖总回复 143 楼拥有证书:学者 笔友
注册于 2009/01/22 07:39:39最后登录 2018/01/10 01:22:29
主体类型:个人
所属领域:无
认证方式:邮箱
IP归属地:0

个人简介

暂未填写
笔记
{{note.content}}
{{n.user.username}}
{{fromNow(n.toc)}} {{n.status === noteStatus.disabled ? "已屏蔽" : ""}} {{n.status === noteStatus.unknown ? "正在审核" : ""}} {{n.status === noteStatus.deleted ? '已删除' : ''}}
  • 编辑
  • 删除
  • {{n.status === 'disabled' ? "解除屏蔽" : "屏蔽" }}
我也是有底线的