# configuring function

Page 1 of 1

## 2 Replies - 1154 Views - Last Post: 12 February 2008 - 11:31 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=43043&amp;s=a8f2219bf26f9ef7e9fc55d7d12d15f4&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 jrb47

Reputation: 0
• Posts: 33
• Joined: 21-April 07

# configuring function

Posted 11 February 2008 - 10:34 PM

I am working on a programming assignment.
I have a few questions as the book is ambiguous to say the least.
PROJECT: create page that allows purchase of variable quantity of two items, totals and then figures tax. I have gotten as far as figuring the subtotal of the individual items. The problem I am having is getting started with the function for figuring the tax and then the total sale.

Here is the code

```<script language="vb" runat="server">
Dim pinkfloydshirt As Decimal
Dim wowhat As Decimal

Dim subtotal As Decimal
Dim subtotal2 As Decimal
Dim subtotal3 As Decimal
Dim totalsale AS Decimal

Dim tax As decimal
tax = Findtax(subtotal3)

pinkfloydshirt = 14.99
wowhat = 8.99

totalsale = subtotal3 + tax

Message1.text = "Pink Floyd Tshirt Cost \$" & pinkfloydshirt
Message2.text = "Wow Hat Cost \$" & wowhat

if shirtquantity.Text <> "" then
subtotal = shirtquantity.text * pinkfloydshirt
Message3.text = subtotal
subtotal3 = subtotal
end if

if hatquantity.Text <> "" then
subtotal2 = hatquantity.text * wowhat
Message4.text = subtotal2
subtotal3 = subtotal3 + subtotal2
Message5.text = "your subtotal for order is \$" & subtotal3
Message7.text = "sales tax is \$" & tax
Message6.text = "Total order is \$" & totalsale
end if

End Sub

Function Findtax(subtotal3 as decimal) As Decimal
Dim tax As decimal
tax = subtotal3 * .08
return tax
End Function

</script>

<html>
<title>Sample Function Page</title>
<body>
<h2>Thank  you for Shopping at Shirts and More.</h2>

<form runat="server">
<asp:label id="message1" runat="server"/> <br/>
Quantity ordered
<asp:textbox id="shirtquantity" runat="server" /><br />
<asp:label id="message3" runat="server"/> <br/><br />

<asp:label id="message2" runat="server"/> <br/>
Quantity ordered
<asp:textbox id="hatquantity" runat="server" /><br />
<asp:label id="message4" runat="server"/> <br/><br />

<asp:label id="message5" runat="server"/> <br/>
<asp:label id="message7" runat="server"/> <br/>
<asp:label id="message6" runat="server"/> <br/><br />

<input type="Submit">
</form>

</body>
</html>

```

Thanks for any help
Jess

This post has been edited by jrb47: 12 February 2008 - 01:03 AM

Is This A Good Question/Topic? 0

## Replies To: configuring function

Reputation: 0
• Posts: 6
• Joined: 12-February 08

## Re: configuring function

Posted 12 February 2008 - 03:18 PM

jrb47, on 11 Feb, 2008 - 10:34 PM, said:

I am working on a programming assignment.
I have a few questions as the book is ambiguous to say the least.
PROJECT: create page that allows purchase of variable quantity of two items, totals and then figures tax. I have gotten as far as figuring the subtotal of the individual items. The problem I am having is getting started with the function for figuring the tax and then the total sale.

Here is the code

```<script language="vb" runat="server">
Dim pinkfloydshirt As Decimal
Dim wowhat As Decimal

Dim subtotal As Decimal
Dim subtotal2 As Decimal
Dim subtotal3 As Decimal
Dim totalsale AS Decimal

Dim tax As decimal
tax = Findtax(subtotal3)

pinkfloydshirt = 14.99
wowhat = 8.99

totalsale = subtotal3 + tax

Message1.text = "Pink Floyd Tshirt Cost \$" & pinkfloydshirt
Message2.text = "Wow Hat Cost \$" & wowhat

if shirtquantity.Text <> "" then
subtotal = shirtquantity.text * pinkfloydshirt
Message3.text = subtotal
subtotal3 = subtotal
end if

if hatquantity.Text <> "" then
subtotal2 = hatquantity.text * wowhat
Message4.text = subtotal2
subtotal3 = subtotal3 + subtotal2
Message5.text = "your subtotal for order is \$" & subtotal3
Message7.text = "sales tax is \$" & tax
Message6.text = "Total order is \$" & totalsale
end if

End Sub

Function Findtax(subtotal3 as decimal) As Decimal
Dim tax As decimal
tax = subtotal3 * .08
return tax
End Function

</script>

<html>
<title>Sample Function Page</title>
<body>
<h2>Thank  you for Shopping at Shirts and More.</h2>

<form runat="server">
<asp:label id="message1" runat="server"/> <br/>
Quantity ordered
<asp:textbox id="shirtquantity" runat="server" /><br />
<asp:label id="message3" runat="server"/> <br/><br />

<asp:label id="message2" runat="server"/> <br/>
Quantity ordered
<asp:textbox id="hatquantity" runat="server" /><br />
<asp:label id="message4" runat="server"/> <br/><br />

<asp:label id="message5" runat="server"/> <br/>
<asp:label id="message7" runat="server"/> <br/>
<asp:label id="message6" runat="server"/> <br/><br />

<input type="Submit">
</form>

</body>
</html>

```

Thanks for any help
Jess

You probably can't find the tax and subtotal or grand total before you find the subtotal
So this should be the last line of code before you find the grand total
tax = Findtax(subtotal3)

```
if shirtquantity.Text <> "" then
subtotal = shirtquantity.text * pinkfloydshirt
Message3.text = subtotal
subtotal3 = subtotal
end if

if hatquantity.Text <> "" then
subtotal2 = hatquantity.text * wowhat
Message4.text = subtotal2
subtotal3 = subtotal3 + subtotal2
Message5.text = "your subtotal for order is \$" & subtotal3

tax = FindTax(subtotal3)

Message7.text = "sales tax is \$" & tax
Message6.text = "Total order is \$" & totalsale
end if

```

You need to do the totalsales around the area where you figure out tax too.

HTH.

### #3 cprmnm

Reputation: 0
• Posts: 2
• Joined: 27-December 07

## Re: configuring function

Posted 12 February 2008 - 11:31 PM

dygytalnomad, on 12 Feb, 2008 - 03:18 PM, said:

jrb47, on 11 Feb, 2008 - 10:34 PM, said:

I am working on a programming assignment.
I have a few questions as the book is ambiguous to say the least.
PROJECT: create page that allows purchase of variable quantity of two items, totals and then figures tax. I have gotten as far as figuring the subtotal of the individual items. The problem I am having is getting started with the function for figuring the tax and then the total sale.

Here is the code

```<script language="vb" runat="server">
Dim pinkfloydshirt As Decimal
Dim wowhat As Decimal

Dim subtotal As Decimal
Dim subtotal2 As Decimal
Dim subtotal3 As Decimal
Dim totalsale AS Decimal

Dim tax As decimal
tax = Findtax(subtotal3)

pinkfloydshirt = 14.99
wowhat = 8.99

totalsale = subtotal3 + tax

Message1.text = "Pink Floyd Tshirt Cost \$" & pinkfloydshirt
Message2.text = "Wow Hat Cost \$" & wowhat

if shirtquantity.Text <> "" then
subtotal = shirtquantity.text * pinkfloydshirt
Message3.text = subtotal
subtotal3 = subtotal
end if

if hatquantity.Text <> "" then
subtotal2 = hatquantity.text * wowhat
Message4.text = subtotal2
subtotal3 = subtotal3 + subtotal2
Message5.text = "your subtotal for order is \$" & subtotal3
Message7.text = "sales tax is \$" & tax
Message6.text = "Total order is \$" & totalsale
end if

End Sub

Function Findtax(subtotal3 as decimal) As Decimal
Dim tax As decimal
tax = subtotal3 * .08
return tax
End Function

</script>

<html>
<title>Sample Function Page</title>
<body>
<h2>Thank  you for Shopping at Shirts and More.</h2>

<form runat="server">
<asp:label id="message1" runat="server"/> <br/>
Quantity ordered
<asp:textbox id="shirtquantity" runat="server" /><br />
<asp:label id="message3" runat="server"/> <br/><br />

<asp:label id="message2" runat="server"/> <br/>
Quantity ordered
<asp:textbox id="hatquantity" runat="server" /><br />
<asp:label id="message4" runat="server"/> <br/><br />

<asp:label id="message5" runat="server"/> <br/>
<asp:label id="message7" runat="server"/> <br/>
<asp:label id="message6" runat="server"/> <br/><br />

<input type="Submit">
</form>

</body>
</html>

```

Thanks for any help
Jess

You probably can't find the tax and subtotal or grand total before you find the subtotal
So this should be the last line of code before you find the grand total
tax = Findtax(subtotal3)

```
if shirtquantity.Text <> "" then
subtotal = shirtquantity.text * pinkfloydshirt
Message3.text = subtotal
subtotal3 = subtotal
end if

if hatquantity.Text <> "" then
subtotal2 = hatquantity.text * wowhat
Message4.text = subtotal2
subtotal3 = subtotal3 + subtotal2
Message5.text = "your subtotal for order is \$" & subtotal3

tax = FindTax(subtotal3)

Message7.text = "sales tax is \$" & tax
Message6.text = "Total order is \$" & totalsale
end if

```

You need to do the totalsales around the area where you figure out tax too.

HTH.

hI friends can u help me to create a forum in asp.net

jrb47, on 11 Feb, 2008 - 10:34 PM, said:

I am working on a programming assignment.
I have a few questions as the book is ambiguous to say the least.
PROJECT: create page that allows purchase of variable quantity of two items, totals and then figures tax. I have gotten as far as figuring the subtotal of the individual items. The problem I am having is getting started with the function for figuring the tax and then the total sale.

Here is the code

```<script language="vb" runat="server">
Dim pinkfloydshirt As Decimal
Dim wowhat As Decimal

Dim subtotal As Decimal
Dim subtotal2 As Decimal
Dim subtotal3 As Decimal
Dim totalsale AS Decimal

Dim tax As decimal
tax = Findtax(subtotal3)

pinkfloydshirt = 14.99
wowhat = 8.99

totalsale = subtotal3 + tax

Message1.text = "Pink Floyd Tshirt Cost \$" & pinkfloydshirt
Message2.text = "Wow Hat Cost \$" & wowhat

if shirtquantity.Text <> "" then
subtotal = shirtquantity.text * pinkfloydshirt
Message3.text = subtotal
subtotal3 = subtotal
end if

if hatquantity.Text <> "" then
subtotal2 = hatquantity.text * wowhat
Message4.text = subtotal2
subtotal3 = subtotal3 + subtotal2
Message5.text = "your subtotal for order is \$" & subtotal3
Message7.text = "sales tax is \$" & tax
Message6.text = "Total order is \$" & totalsale
end if

End Sub

Function Findtax(subtotal3 as decimal) As Decimal
Dim tax As decimal
tax = subtotal3 * .08
return tax
End Function

</script>

<html>
<title>Sample Function Page</title>
<body>
<h2>Thank  you for Shopping at Shirts and More.</h2>

<form runat="server">
<asp:label id="message1" runat="server"/> <br/>
Quantity ordered
<asp:textbox id="shirtquantity" runat="server" /><br />
<asp:label id="message3" runat="server"/> <br/><br />

<asp:label id="message2" runat="server"/> <br/>
Quantity ordered
<asp:textbox id="hatquantity" runat="server" /><br />
<asp:label id="message4" runat="server"/> <br/><br />

<asp:label id="message5" runat="server"/> <br/>
<asp:label id="message7" runat="server"/> <br/>
<asp:label id="message6" runat="server"/> <br/><br />

<input type="Submit">
</form>

</body>
</html>

```

Thanks for any help
Jess