|
-
Sep 9th, 2008, 10:20 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Problem with Numbers
I have a number that appears in a text box, but the number sometimes has a decimal...
Lets say I have the number 2, sometimes it will show up as 2.(then another number)
Without writing a huge code saying:
Code:
If input.Text = 2.1 Then
output.Text = 2
ElseIf input.Text = 2.2 Then
output.Text = 2
' etc, etc, etc, etc, etc, etc, etc... Long!
End If
Is there a way I can just take the number, and remove the decimal, and the number after it?
The number is always different, could be 2, could be 9, could be anyting.
Thanks for your help!
-
Sep 9th, 2008, 11:44 PM
#2
Re: Problem with Numbers
Perhaps you have to write a trillion lines like that to cover all combinations!!!
Code:
output.Text = Int(input.Text)
-
Sep 9th, 2008, 11:48 PM
#3
Re: Problem with Numbers
What about this???
Code:
Text1.text=left(text1.text,instr(1,text1.text,".")-1)
Will this help you???
-Best wishes
Akhilesh
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Sep 9th, 2008, 11:51 PM
#4
Re: Problem with Numbers
If you have 2.7 in the textbox, then if you use the code that anhn had posted,
Code:
output.Text = Int(input.Text)
it will give you the result 3
Am I right, Anhn..???
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Sep 10th, 2008, 12:17 AM
#5
Re: Problem with Numbers
No, Int() will always show the first integer equal to or less than the value. So Int(2.7) will return 2.
However, for negative numbers, the integer part gets bigger because, as noted, Int() always returns the integer <= the number. So Int(-2.7) returns -3.
Fix() is exactly like Int() for positive numbers, but goes the other way for negatives:
Int(2.7) = 2
Int(-2.7) = 3
Fix(2.7) = 2
Fix(-2.7) = -2
Fix() can be said to simply strip off the decimal portion of the number.
-
Sep 10th, 2008, 12:23 AM
#6
Re: Problem with Numbers
Thanks for clearing it, Ellis...
VB6 is not installed in this computer, so I was not able to check it... That's why asked that int() problem... Thanks again...
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Sep 10th, 2008, 12:23 AM
#7
Re: Problem with Numbers
A typo there Ellis: Int(-2.7) = -3 as you mentioned above.
-
Sep 10th, 2008, 12:26 AM
#8
Re: Problem with Numbers
 Originally Posted by akhileshbc
Thanks for clearing it, Ellis... 
VB6 is not installed in this computer, so I was not able to check it... That's why asked that int() problem... Thanks again... 
Do you have Excel/Word installed on that computer?
That is common code for VBA/VB6.
-
Sep 10th, 2008, 12:43 AM
#9
Re: Problem with Numbers
Do you have Excel/Word installed on that computer?
That is common code for VBA/VB6.
No, this is my testing machine....
Softwares that I had developed will be tested in here....
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Sep 10th, 2008, 07:58 AM
#10
Thread Starter
Hyperactive Member
Re: Problem with Numbers
Thanks so much foer the help guys!
Heres my code, I'm getting an identifyer error:
Code:
Fix (theDoc.selectSingleNode("//value").Text) = ExternalValue.Caption
I'm loading the number from a XML file, then putting it in a label... It doesnt seem to be working, whats wrong?
Thanks
-
Sep 10th, 2008, 12:59 PM
#11
Re: Problem with Numbers
Externalvalue.Caption=fix(val(thedoc.Selectsinglenode("//value").Text))
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Sep 10th, 2008, 03:05 PM
#12
Thread Starter
Hyperactive Member
Re: Problem with Numbers
Thank you everyone for your help, I have no solved the issue! Works perfectly!
Thank you!
-
Sep 11th, 2008, 12:51 AM
#13
Re: [RESOLVED] Problem with Numbers
If your problem is solved, then mark the thread as RESOLVED 
-Best wishes
Akhilesh
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
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
|