[求助]明天交呀,救救我呀!
我们ACCESS老师叫我们做一个二次方程的求解VB代码呀, 我做的是这样的 可是出现了 Private Sub cmdOK_Click() Dim a, b, c, r As Long Dim x1, x2 As Single Me.txta.SetFocus a = Me.txta.Text Me.txtb.SetFocus b = Me.txtb.Text Me.txtc.SetFocus c = Me.txtc.Text r = b * b - 4 * a * c Me.txtx.SetFocus Me.txtg.SetFocus If r < 0 Then Me.txtg.Text = "此时方程有两个虚根!" x1 = (-b) / (2 * a) - Abs(r) / (2 * a) x2 = (-b) / (2 * a) + Abs(r) / (2 * a) Me.txtx.Text = x1 & "i" & "或" & x2 & "i" ElseIf r = 0 Then x1 = (-b) / (2 * a) Me.txtx.Text = x1 Me.txtg.Text = "此时方程只有一个实根!" Else x1 = (-b) - Abs(r) / (2 * a) x2 = (-b) + Abs(r) / (2 * a) Me.txtx.Text = x1 & x2 Me.txtg.Text = "此时方程有两个不等的实根!" End If
End Sub 运行时错误'2185'; 除非控件获得焦点,否则您不能引用该控件的属性和方法 这是为什么呀,大家快点帮我呀!!!!