PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
why will this program not build or run?
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
why will this program not build or run?
![]() |
why will this program not build or run? |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I've got this simple program that will not build or run, any idea
what I am doing wrong? Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click Dim c As Double = CDbl(txtOrderCost.Text) Dim r As Integer = CInt(txtMonthlyDemand.Text) Dim p As Double = CDbl(txtPartCost.Text) Dim f As Double = 0.15 Dim h As Double = p * f Dim eoq As Double = 0 eoq = (p / r) * 0.15 * 332100 lblEOQ.Text = "EOQ = " & eoq End Sub |
|
|
|
#2 |
|
Guest
Posts: n/a
|
A double is expection whole numbers & not 0.15
try using 'Decimal' as the result instead of 'Double' Example: Dim eoq As Decimal = (p / r) * 0.15 * 332100 lblEOQ.Text = "EOQ = " & eoq I haven't tried your code because you never gave any possible values for OrderCost, MonthlyDemand or PartCost -- Newbie Coder (It's just a name) |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Well, if it won't compile (build) then it certainly won't run so the fact
that it won't run is irrevalent. What compile-time error(s) are you getting? "Ron" <pts4560@yahoo.com> wrote in message news:1171327952.257787.296650@v45g2000cwv.googlegroups.com... > I've got this simple program that will not build or run, any idea > what I am doing wrong? > > Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e > As System.EventArgs) Handles btnCalculate.Click > Dim c As Double = CDbl(txtOrderCost.Text) > Dim r As Integer = CInt(txtMonthlyDemand.Text) > Dim p As Double = CDbl(txtPartCost.Text) > Dim f As Double = 0.15 > Dim h As Double = p * f > Dim eoq As Double = 0 > > eoq = (p / r) * 0.15 * 332100 > > lblEOQ.Text = "EOQ = " & eoq > > End Sub > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
OK here is what I have for the code now and it still will not load my
form when I run it. Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click Dim c As Double = CDbl(txtOrderCost.Text) Dim r As Integer = CInt(txtMonthlyDemand.Text) Dim p As Double = CDbl(txtPartCost.Text) Dim f As Decimal = CDec(0.15) Dim h As Double = p * f Dim eoq As Decimal = CDec((p / r) * 0.15 * 332100) 'for the eoq, use the below formula as a guide 'replace with correct formula 'eoq = CDec((p / r) * 0.15 * 332100) lblEOQ.Text = "EOQ = " & eoq End Sub FOR THE INPUTS I AM USING : order cost 25.00 Monthly demand 90000 Part cost 18.75 Thats what I want to use but the form never opens for me to enter them in, I dont even get that far. On Feb 12, 8:04 pm, "Newbie Coder" <newbieco...@spammeplease.com> wrote: > A double is expection whole numbers & not 0.15 > > try using 'Decimal' as the result instead of 'Double' > > Example: > > Dim eoq As Decimal = (p / r) * 0.15 * 332100 > lblEOQ.Text = "EOQ = " & eoq > > I haven't tried your code because you never gave any possible values for > OrderCost, MonthlyDemand or PartCost > > -- > Newbie Coder > (It's just a name) |
|
|
|
#5 |
|
Guest
Posts: n/a
|
On Feb 12, 8:36 pm, "Ron" <pts4...@yahoo.com> wrote:
> OK here is what I have for the code now and it still will not load my > form when I run it. > > Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal > e As System.EventArgs) Handles btnCalculate.Click > Dim c As Double = CDbl(txtOrderCost.Text) > Dim r As Integer = CInt(txtMonthlyDemand.Text) > Dim p As Double = CDbl(txtPartCost.Text) > Dim f As Decimal = CDec(0.15) > Dim h As Double = p * f > Dim eoq As Decimal = CDec((p / r) * 0.15 * 332100) > > 'for the eoq, use the below formula as a guide > 'replace with correct formula > 'eoq = CDec((p / r) * 0.15 * 332100) > > lblEOQ.Text = "EOQ = " & eoq > > End Sub > FOR THE INPUTS I AM USING : > order cost 25.00 > Monthly demand 90000 > Part cost 18.75 > Thats what I want to use but the form never opens for me to enter them > in, I dont even get that far. > > On Feb 12, 8:04 pm, "Newbie Coder" <newbieco...@spammeplease.com> > wrote: > > > > > A double is expection whole numbers & not 0.15 > > > try using 'Decimal' as the result instead of 'Double' > The only error I get says the program has exited with e 0 (0x0) > > Example: > > > Dim eoq As Decimal = (p / r) * 0.15 * 332100 > > lblEOQ.Text = "EOQ = " & eoq > > > I haven't tried your code because you never gave any possible values for > > OrderCost, MonthlyDemand or PartCost > > > -- > > Newbie Coder > > (It's just a name)- Hide quoted text - > > - Show quoted text - |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Hmmm. I just created a new project in VB 2005 and craeted the 3 text boxes
that you listed, the one label, and the calculate button. I did not have any problems at all running the program. It would take all but 3 minutes, have you tried creating a completely new project and trying this again? Tony "Ron" <pts4560@yahoo.com> wrote in message news:1171330761.738031.61140@m58g2000cwm.googlegroups.com... > On Feb 12, 8:36 pm, "Ron" <pts4...@yahoo.com> wrote: >> OK here is what I have for the code now and it still will not load my >> form when I run it. >> >> Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal >> e As System.EventArgs) Handles btnCalculate.Click >> Dim c As Double = CDbl(txtOrderCost.Text) >> Dim r As Integer = CInt(txtMonthlyDemand.Text) >> Dim p As Double = CDbl(txtPartCost.Text) >> Dim f As Decimal = CDec(0.15) >> Dim h As Double = p * f >> Dim eoq As Decimal = CDec((p / r) * 0.15 * 332100) >> >> 'for the eoq, use the below formula as a guide >> 'replace with correct formula >> 'eoq = CDec((p / r) * 0.15 * 332100) >> >> lblEOQ.Text = "EOQ = " & eoq >> >> End Sub >> FOR THE INPUTS I AM USING : >> order cost 25.00 >> Monthly demand 90000 >> Part cost 18.75 >> Thats what I want to use but the form never opens for me to enter them >> in, I dont even get that far. >> >> On Feb 12, 8:04 pm, "Newbie Coder" <newbieco...@spammeplease.com> >> wrote: >> >> >> >> > A double is expection whole numbers & not 0.15 >> >> > try using 'Decimal' as the result instead of 'Double' >> > The only error I get says the program has exited with e 0 (0x0) > >> > Example: >> >> > Dim eoq As Decimal = (p / r) * 0.15 * 332100 >> > lblEOQ.Text = "EOQ = " & eoq >> >> > I haven't tried your code because you never gave any possible values >> > for >> > OrderCost, MonthlyDemand or PartCost >> >> > -- >> > Newbie Coder >> > (It's just a name)- Hide quoted text - >> >> - Show quoted text - > > |
|
|
|
#7 |
|
Guest
Posts: n/a
|
Describing what happens in the first place is always a good idea ;-)
For now it would make me thought that you just show the form. But showing the form doesn't mean that control is necessarily transfered to the form. In this case the program just continues and ends... What is your startup object ? IMO the relevant code is the code that launch the forms... "Ron" <pts4560@yahoo.com> a écrit dans le message de news: 1171330761.738031.61140@m58g2000cwm.googlegroups.com... > On Feb 12, 8:36 pm, "Ron" <pts4...@yahoo.com> wrote: >> OK here is what I have for the code now and it still will not load my >> form when I run it. >> >> Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal >> e As System.EventArgs) Handles btnCalculate.Click >> Dim c As Double = CDbl(txtOrderCost.Text) >> Dim r As Integer = CInt(txtMonthlyDemand.Text) >> Dim p As Double = CDbl(txtPartCost.Text) >> Dim f As Decimal = CDec(0.15) >> Dim h As Double = p * f >> Dim eoq As Decimal = CDec((p / r) * 0.15 * 332100) >> >> 'for the eoq, use the below formula as a guide >> 'replace with correct formula >> 'eoq = CDec((p / r) * 0.15 * 332100) >> >> lblEOQ.Text = "EOQ = " & eoq >> >> End Sub >> FOR THE INPUTS I AM USING : >> order cost 25.00 >> Monthly demand 90000 >> Part cost 18.75 >> Thats what I want to use but the form never opens for me to enter them >> in, I dont even get that far. >> >> On Feb 12, 8:04 pm, "Newbie Coder" <newbieco...@spammeplease.com> >> wrote: >> >> >> >> > A double is expection whole numbers & not 0.15 >> >> > try using 'Decimal' as the result instead of 'Double' >> > The only error I get says the program has exited with e 0 (0x0) > >> > Example: >> >> > Dim eoq As Decimal = (p / r) * 0.15 * 332100 >> > lblEOQ.Text = "EOQ = " & eoq >> >> > I haven't tried your code because you never gave any possible values >> > for >> > OrderCost, MonthlyDemand or PartCost >> >> > -- >> > Newbie Coder >> > (It's just a name)- Hide quoted text - >> >> - Show quoted text - > > |
|
|
|
#8 |
|
Guest
Posts: n/a
|
Ron
I have used the values you have given me & I get the result of: 'EOQ = 103.78125' Here is the code: Dim c As Double = 25.00 Dim r As Integer = 9000 Dim p As Double = 18.75 Dim f As Double = 0.15 Dim h As Double = p * f Dim eoq As Double = CDbl((p / r) * 0.15 * 332100) TextBox1.Text = "EOQ = " & eoq The code compiles for me ok with no errors Maybe you don't need 5 decimal places then it could be formatted simply by: TextBox1.Text = "EOQ = " & Format(eoq, "#.###") Result: 'EOQ = 103.781' This will give you the whole number & then to 3 decimal places: TextBox1.Text = "EOQ = " & Format(eoq, "#.##") Result: 'EOQ = 103.78' The above to 2 decimal places & so on I hope this helps, -- Newbie Coder (It's just a name) |
|
|
|
#9 |
|
Guest
Posts: n/a
|
thanks everyone. I started a new project and redid it and it compiled
fine. On Feb 13, 11:46 am, "Newbie Coder" <newbieco...@spammeplease.com> wrote: > Ron > > I have used the values you have given me & I get the result of: 'EOQ = > 103.78125' > > Here is the code: > > Dim c As Double = 25.00 > Dim r As Integer = 9000 > Dim p As Double = 18.75 > Dim f As Double = 0.15 > Dim h As Double = p * f > Dim eoq As Double = CDbl((p / r) * 0.15 * 332100) > TextBox1.Text = "EOQ = " & eoq > > The code compiles for me ok with no errors > > Maybe you don't need 5 decimal places then it could be formatted simply by: > > TextBox1.Text = "EOQ = " & Format(eoq, "#.###") > Result: 'EOQ = 103.781' > > This will give you the whole number & then to 3 decimal places: > > TextBox1.Text = "EOQ = " & Format(eoq, "#.##") > Result: 'EOQ = 103.78' > > The above to 2 decimal places & so on > > I hope this helps, > > -- > Newbie Coder > (It's just a name) |
|
|
|
#10 |
|
Guest
Posts: n/a
|
Glad you had a result, Ron
-- Newbie Coder (It's just a name) |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

