Outputting a total in an array

Ian96
01-11-2004, 05:51 AM
i have this code

Dim total1 As Integer = Int32.Parse(txtline2.Text)
Dim total2 As Integer = Int32.Parse(txtline6.Text)
MessageBox.Show("Totals Are: " & total1)
MessageBox.Show("Total Is Are: " & total2)

but it wont accept dots as in 2.35 what do i need to do to allow this to work. Im geussing its something to do with the integer

Naghual
01-11-2004, 05:55 AM
Dim total1 As single
Dim total2 As single

total1 = Int32.Parse(txtline2.Text)
total2 = Int32.Parse(txtline6.Text)

MessageBox.Show("Totals Are: " & total1)
MessageBox.Show("Total Is Are: " & total2)

Ian96
01-11-2004, 06:14 AM
It still does not like it. I am using vb.net 2003 does that have something to do with it

Ian96
01-11-2004, 06:16 AM
it works when i put in 250 but not 2.50

Naghual
01-11-2004, 06:19 AM
Maybe in OS decimal delimiter is ","?

Ian96
01-11-2004, 06:38 AM
Where would i find that decimal delimiter?

Naghual
01-11-2004, 06:43 AM
In Control Panel\Regional Settings..

In code through GetSystemMetrics API function

To quick determining start Excel and enter 2,00 in a cell
If it will converted to 2 then "," is a decimal delimiter

Ian96
01-11-2004, 06:46 AM
yeh in excel i type 2.00 in a cell and it changes to 2

Naghual
01-11-2004, 06:50 AM
Ok
"." is delimeter.

Try this

Dim total1 As Single
Dim total2 As Single

total1 = CSng(Int32.Parse(txtline2.Text))
total2 = CSng(Int32.Parse(txtline6.Text))

MessageBox.Show("Totals Are: " & total1)
MessageBox.Show("Total Is Are: " & total2)

And what is "Int32.Parse" ?

Ian96
01-11-2004, 06:59 AM
its done by this

Dim total1 As Single
Dim total2 As Single

total1 = CSng(txtline2.Text)
total2 = CSng(txtline6.Text)

MessageBox.Show("Totals Are: " & total1)
MessageBox.Show("Total Is Are: " & total2)

it did not like the int32.parse which is some form of integer number. I was using it at college but i dont know exactly what it is, just that it works with whole numbers ONLY lol

thanks

Iceplug
01-11-2004, 07:02 AM
OK (This wouldn't have happened if it was under .NET in the first place).

After you have dimmed the totals as Single:
total1 = Single.Parse(txtline2.Text)
(Or System.Convert.ToSingle())

MessageBox.Show("Totals are: " & total1.ToString())

Also, what is "Total Is Are"? :)

Naghual
01-11-2004, 07:03 AM
your wellcome

Ian96
01-11-2004, 08:05 AM
Thanks i will post more in the .NET section now i have vb.net then.

lol i corrected that error

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum