|
-
Apr 14th, 2005, 08:43 AM
#1
Thread Starter
Frenzied Member
mathematical operations on text boxes
Hello
I have got the following code
Code:
CableLos = CableLoss.Text + OTSR_splitterLoss.Text
i stick the value 3 in cableloss.text
and 3 in OTSR_splitterloss.text
and i get the value 33 !!
can you guys tell me how to do a sum on these two text boxes.
-
Apr 14th, 2005, 10:47 AM
#2
Re: mathematical operations on text boxes
One of many ways would be to use the Val statement.
VB Code:
CableLos = Val(CableLoss.Text) + Val(OTSR_splitterLoss.Text)
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 14th, 2005, 12:13 PM
#3
Fanatic Member
Re: mathematical operations on text boxes
A good thing to remember is that any time that you use math on user input to be sure to convert it to a number. You can use Val() as RobDog suggested or one of the conversion functions.
CByte() - Byte
CInt() - Integer
CLng() - Long
CDbl() - Double
CSng() - Single
CCur() - Currency
-
Apr 15th, 2005, 06:01 AM
#4
Thread Starter
Frenzied Member
Re: mathematical operations on text boxes
thanks dudes
i used the ccur to convert it to currencies
what would the difference between vall and ccur be?
does val return fractional numbers?
-
Apr 15th, 2005, 11:47 AM
#5
Frenzied Member
Re: mathematical operations on text boxes
 Originally Posted by Psyrus
A good thing to remember is that any time that you use math on user input to be sure to convert it to a number. You can use Val() as RobDog suggested or one of the conversion functions.
CByte() - Byte
CInt() - Integer
CLng() - Long
CDbl() - Double
CSng() - Single
CCur() - Currency
Unless it's a date, then use CDate()
Tengo mas preguntas que contestas
-
Apr 15th, 2005, 12:04 PM
#6
Re: mathematical operations on text boxes
 Originally Posted by vb_student
does val return fractional numbers?
Val returns whole numbers. If you did a val on 3.5, it would return 4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|