PC Review Forums Newsgroups Microsoft DotNet Microsoft VB .NET why will this program not build or run?

Reply

why will this program not build or run?

 
Thread Tools Rate Thread
Old 13-02-2007, 12:52 AM   #1
Ron
Guest
 
Posts: n/a
Default why will this program not build or run?


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

  Reply With Quote
Old 13-02-2007, 01:04 AM   #2
Newbie Coder
Guest
 
Posts: n/a
Default Re: why will this program not build or run?

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)


  Reply With Quote
Old 13-02-2007, 01:23 AM   #3
Stephany Young
Guest
 
Posts: n/a
Default Re: why will this program not build or run?

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
>


  Reply With Quote
Old 13-02-2007, 01:36 AM   #4
Ron
Guest
 
Posts: n/a
Default Re: why will this program not build or run?

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)



  Reply With Quote
Old 13-02-2007, 01:39 AM   #5
Ron
Guest
 
Posts: n/a
Default Re: why will this program not build or run?

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 -



  Reply With Quote
Old 13-02-2007, 03:05 AM   #6
Tony K
Guest
 
Posts: n/a
Default Re: why will this program not build or run?

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 -

>
>


  Reply With Quote
Old 13-02-2007, 09:03 AM   #7
Patrice
Guest
 
Posts: n/a
Default Re: why will this program not build or run?

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 -

>
>



  Reply With Quote
Old 13-02-2007, 04:46 PM   #8
Newbie Coder
Guest
 
Posts: n/a
Default Re: why will this program not build or run?

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)


  Reply With Quote
Old 13-02-2007, 05:15 PM   #9
Ron
Guest
 
Posts: n/a
Default Re: why will this program not build or run?

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)



  Reply With Quote
Old 13-02-2007, 05:31 PM   #10
Newbie Coder
Guest
 
Posts: n/a
Default Re: why will this program not build or run?

Glad you had a result, Ron

--
Newbie Coder
(It's just a name)


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off