Hello, Can anyone give me any suggestions.
I create a form using excels VB editor. What I have is 5 variable and 5 textboxes for the variables. The program is suppose to allow the user to enter a "TOT POPSIZE" and "ErrorSize", Than once the Calc button is press three results will display in three other textbox which would be a Condidence of 90 answer, Confidence of 95 answer and a Confidence of 99.
Now, my problem is the input textbox should never =0 if they do a MsgBox should appear with a return statement. Can someone help me finish the IF statement. BELOW is my sample code. I know not to sharp that's why I'm here for help!!
Private Sub CommandButton1_Click()
Dim PopSize, ErrSize, ConfUnc90, ConfUnc95, ConfUnc99 As Double
ErrSize = CDbl(txtbox1)
PopSize = CDbl(txtbox2)
If ErrSize = 0 Then
MsgBox ("Population Size should be > 0")
Else
PopSize = 0
MsgBox ("Population Size should be > 0")
Else
ErrSize = eval(form.ErrSize.Value)
form.PopSize.Value = "" + PopSize
form.ErrSize.Value = "" + ErrSize
ConfUnc90 = (0.680625 / ((ErrSize / 100) * (ErrSize / 100)))
ConfUnc95 = (0.9604 / ((ErrSize / 100) * (ErrSize / 100)))
ConfUnc99 = (1.658944 / ((ErrSize / 100) * (ErrSize / 100)))
ConfUnc90.Value = "" + Math.Round(ConfUnc90)
ConfUnc95.Value = "" + Math.Round(ConfUnc95)
ConfUnc99.Value = "" + Math.Round(ConfUnc99)
ConfSamp90.Value = "" + Math.Round((ConfUnc90 * PopSize) / (ConfUnc90 + PopSize))
ConfSamp95.Value = "" + Math.Round((ConfUnc95 * PopSize) / (ConfUnc95 + PopSize))
ConfSamp99.Value = "" + Math.Round((ConfUnc99 * PopSize) / (ConfUnc99 + PopSize))
End If
End Sub
I create a form using excels VB editor. What I have is 5 variable and 5 textboxes for the variables. The program is suppose to allow the user to enter a "TOT POPSIZE" and "ErrorSize", Than once the Calc button is press three results will display in three other textbox which would be a Condidence of 90 answer, Confidence of 95 answer and a Confidence of 99.
Now, my problem is the input textbox should never =0 if they do a MsgBox should appear with a return statement. Can someone help me finish the IF statement. BELOW is my sample code. I know not to sharp that's why I'm here for help!!
Private Sub CommandButton1_Click()
Dim PopSize, ErrSize, ConfUnc90, ConfUnc95, ConfUnc99 As Double
ErrSize = CDbl(txtbox1)
PopSize = CDbl(txtbox2)
If ErrSize = 0 Then
MsgBox ("Population Size should be > 0")
Else
PopSize = 0
MsgBox ("Population Size should be > 0")
Else
ErrSize = eval(form.ErrSize.Value)
form.PopSize.Value = "" + PopSize
form.ErrSize.Value = "" + ErrSize
ConfUnc90 = (0.680625 / ((ErrSize / 100) * (ErrSize / 100)))
ConfUnc95 = (0.9604 / ((ErrSize / 100) * (ErrSize / 100)))
ConfUnc99 = (1.658944 / ((ErrSize / 100) * (ErrSize / 100)))
ConfUnc90.Value = "" + Math.Round(ConfUnc90)
ConfUnc95.Value = "" + Math.Round(ConfUnc95)
ConfUnc99.Value = "" + Math.Round(ConfUnc99)
ConfSamp90.Value = "" + Math.Round((ConfUnc90 * PopSize) / (ConfUnc90 + PopSize))
ConfSamp95.Value = "" + Math.Round((ConfUnc95 * PopSize) / (ConfUnc95 + PopSize))
ConfSamp99.Value = "" + Math.Round((ConfUnc99 * PopSize) / (ConfUnc99 + PopSize))
End If
End Sub