Problem with Vb dividing
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
10 posts
Page 1 of 1
Hi im making a convertor and i need help with dividing when i do ex."label1.text/1024" the answer comes up something like 1.79696973E+25 how can i get rid of that e+25 and making it display as a normal number? and round it to 10 decimal places.



A bit of the code:



A bit of the code:
Code: Select all
If ComboBox1.Text = "Bits" Then
Label9.Text = TextBox1.Text
Label10.Text = Label9.Text / 8
Label11.Text = Label10.Text / 1024
Label12.Text = Label11.Text / 1024
Label13.Text = Label12.Text / 1024
Label14.Text = Label13.Text / 1024
Label15.Text = Label14.Text / 1024
Label16.Text = Label15.Text / 1024
Label18.Text = Label16.Text / 1024
Label21.Text = Label18.Text / 1024
ElseIf ComboBox1.Text = "Bytes" Then
Label9.Text = Label10.Text * 8
Label10.Text = TextBox1.Text
Label11.Text = Label10.Text / 1024
Label12.Text = Label11.Text / 1024
Label13.Text = Label12.Text / 1024
Label14.Text = Label13.Text / 1024
Label15.Text = Label14.Text / 1024
Label16.Text = Label15.Text / 1024
Label18.Text = Label16.Text / 1024
Label21.Text = Label18.Text / 1024
ElseIf ComboBox1.Text = "Kilobytes" Then
Label9.Text = Label10.Text * 8
Label10.Text = Label11.Text * 1024
Label11.Text = TextBox1.Text
Label12.Text = Label11.Text / 1024
Label13.Text = Label12.Text / 1024
Label14.Text = Label13.Text / 1024
Label15.Text = Label14.Text / 1024
Label16.Text = Label15.Text / 1024
Label18.Text = Label16.Text / 1024
Label21.Text = Label18.Text / 1024
ElseIf ComboBox1.Text = "Megabytes" Then
Label9.Text = Label10.Text * 8
Label10.Text = Label11.Text * 1024
Label11.Text = Label12.Text * 1024
Label12.Text = TextBox1.Text
Label13.Text = Label12.Text / 1024
Label14.Text = Label13.Text / 1024
Label15.Text = Label14.Text / 1024
Label16.Text = Label15.Text / 1024
Label18.Text = Label16.Text / 1024
Label21.Text = Label18.Text / 1024
When you use the divide operator it will return a double (floating point) number.
You can declare the result as an integer type to round up the floating point.
For example:
You can declare the result as an integer type to round up the floating point.
For example:
Code: Select all
Dim int1 As Integer = Label10.Text / 1024
Label11.Text = int1.ToString()
or mandai he could just use Math.round like this
Code: Select all
right? Label2.Text = Math.Round(Label1.Text / 1024, a) 'Where "a" is put how many digits you want
used it like this :
result :
with division it works
Code: Select all
and doesn't work :/ ElseIf ComboBox1.Text = "Yottabytes" Then
Label9.Text = Label10.Text * 8
Label10.Text = Math.Round(Label11.Text * 1024, 4)
Label11.Text = Math.Round(Label12.Text * 1024, 4)
Label12.Text = Math.Round(Label13.Text * 1024, 4)
Label13.Text = Math.Round(Label14.Text * 1024, 4)
Label14.Text = Math.Round(Label15.Text * 1024, 4)
Label15.Text = Math.Round(Label16.Text * 1024, 4)
Label16.Text = Math.Round(Label18.Text * 1024, 4)
Label18.Text = Math.Round(Label21.Text * 1024, 4)
Label21.Text = TextBox1.Text
result :

with division it works
strange i typed
Code: Select all
with 1.2089729872943526873457824356283405742435892345 being label2 and label1 being 0 so i guess try setting the label to 0 then try rounding Label1.Text = Math.Round(Label2.Text * 9216, 5)
That's because I've got realy large numbers not decimals like 1,000,000,000,000,000,000,000 for eg 1yettabyte = 1,208,925,819,614,629,174,706,176 bytes or 2^80 bytes i need to get the standard form i think 2^80 = 1.20892582 × 10^24 anyway to do this on vb?
I think you can use the long data type to display bigger numbers. Or you can write your own ToString function. Search that on google.
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

I think it will be very hard to handle such large numbers
10 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023