Need help finishing code Please!!

cblackst

New Member
Joined
Jan 6, 2005
Messages
39
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
 
Does -

<font face=Courier New>TextBox3.Text = <SPAN style="color:#00007F">CStr</SPAN>(Round((ConfUnc90 * PopSize) / (ConfUnc90 + PopSize)))
TextBox4.Text = <SPAN style="color:#00007F">CStr</SPAN>(Round((ConfUnc95 * PopSize) / (ConfUnc95 + PopSize)))
TextBox5.Text = <SPAN style="color:#00007F">CStr</SPAN>(Round((ConfUnc99 * PopSize) / (ConfUnc99 + PopSize)))</FONT>

substituted for your 3 lines work?
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,214,813
Messages
6,121,706
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top