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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,215,412
Messages
6,124,761
Members
449,187
Latest member
hermansoa

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