Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / June 2005

Tip: Looking for answers? Try searching our database.

need converting to and formating textbox values to decimal data ty

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Newbee Adam - 20 Jun 2005 16:45 GMT
I have been reading in help how I need to use decimal becuase currency does
not exist like I used in vb6.
I had a difficult time on google and msdn finding how or if I can take the
value of text box as decimal or do I just have to make another decimal
variable
. So I took a guess hoping CDec would come up blue if I type it in with no
squigglies on the line. But is this actually converting it to decimal.

Next if so, I do not like the out put to the textboxes
Total: 100
Tax: 4.500    I need it formatted as 4.50
Gross: 95.5  
Split: 48     This is not accurate, it is rounding, It should be of course
half of 95.5,  47.75

<code>
Private Sub Button1_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles btnCalc.Click
       'Button 1 Calculate
       Const Tax As Decimal = 0.045
       Dim a As Integer
       For a = 1 To 5
           lblTotal.Text = CDec(Val(lblTotal.Text)) +
CDec(Val(txtCoinsInArray(a).Text))
       Next
       If chkUncleSam.Checked = True Then
           lblTax.Text = CDec(Val(lblTotal.Text)) * Tax
       End If
       lblGross.Text = CDec(Val(lblTotal.Text)) - CDec(Val(lblTax.Text))
       lblSplit.Text = CDec(Val(lblGross.Text)) \ 2
   End Sub
End Class
</code>
Signature

Adam S

Cor Ligthert - 20 Jun 2005 17:14 GMT
Newbee,

Net1.x uses Bankers Rounding and there are no alternatives

http://support.microsoft.com/default.aspx?scid=kb;en-us;196652

I hope this helps,

Cor
Patrice - 20 Jun 2005 17:20 GMT
\ is the integer division ? What if you try / instead ?

Patrice

> I have been reading in help how I need to use decimal becuase currency does
> not exist like I used in vb6.
[quoted text clipped - 29 lines]
> End Class
> </code>
Newbee Adam - 20 Jun 2005 17:48 GMT
Super Patrice, that was the problem. I will remeber this? "Lean right , to
get the money right!" silly little memory tool!
Signature

Adam S

> \ is the integer division ? What if you try / instead ?
>
[quoted text clipped - 35 lines]
> > End Class
> > </code>
Newbee Adam - 20 Jun 2005 17:51 GMT
is Cdec correct to convert decimal datatype, I could not find it in help?
Signature

Adam S

> Super Patrice, that was the problem. I will remeber this? "Lean right , to
> get the money right!" silly little memory tool!
[quoted text clipped - 38 lines]
> > > End Class
> > > </code>
Patrice - 20 Jun 2005 18:00 GMT
This is part of the VB.NET language (i.e. you'll find in the VB.NET language
specification not in the framework class library doc) :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vaGr
pTypeConversion.asp


Signature

Patrice

> is Cdec correct to convert decimal datatype, I could not find it in help?
>
[quoted text clipped - 40 lines]
> > > > End Class
> > > > </code>
Newbee Adam - 20 Jun 2005 17:57 GMT
is Cdec correct for decimal. I  search in help and could not find? I just
guess.

Signature

Adam S

> \ is the integer division ? What if you try / instead ?
>
[quoted text clipped - 35 lines]
> > End Class
> > </code>

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.