Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB - Convert long String-number to Integer

Tags:

vb.net

Alright, so I'm not exactly very oriented when it comes to functions available in VB. I have a string containing the current date and time and need to convert it to a integer so i can compare the time.

Dim my_str as String = "201308281110"
Dim my_int as Integer = Convert.ToInt32(my_str)

I cant do that with this string apparently. Because I think it is too long for the 32-bit integer. All the other convertions I have tried also fails. That including "ToInt64", "Int", "CInt"... So, any idea how to convert this longer string to an integer?

like image 617
Aleksander Fimreite Avatar asked Jul 22 '26 07:07

Aleksander Fimreite


1 Answers

Why don't you just simply use Date? You can compare Dates with each other, so there's no need to use an integer for comparing.

Dim my_date as Date = DateTime.ParseExact(my_str, "yyyyMMddhhmm", System.Globalization.CultureInfo.InvariantCulture)
like image 118
sloth Avatar answered Jul 24 '26 05:07

sloth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!