473,413 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

VB.NET App: How to convert Unicode String to Integer?

5
I have got one problem in VB.NET 2005 using unicode
I want to add two numbers in vb.net 2005 through UNICODE
I didn't know how to convert UNICODE string to integer.

I hope you can solve my problem
Nov 26 '07 #1
9 6892
debasisdas
8,127 Expert 4TB
Can you post what you have tried so far.
Nov 26 '07 #2
Plater
7,872 Expert 4TB
int.parse() has overloads that might be able to help you with a unicode string?
Nov 26 '07 #3
vaskar
5
Can you post what you have tried so far.
I want to add two NepaliUnicode number as
Expand|Select|Wrap|Line Numbers
  1. Dim a as string=me.textbox1.text
  2. dim b as string=me.textbox2.text
  3. dim c as integer=val(a+b)
  4.  
Above statement throw exception "Input string was not in correct format" Format Exception was unhandled

I have done above coding through this also:
Expand|Select|Wrap|Line Numbers
  1. Dim a as string=Integer.Parse(me.textbox1.text)
  2.  
Above statement throw exception "Input string was not in correct format" Format Exception was unhandled

if you have any idea to convert string to integer but the string is in numeric type unicode.

I could not find solution for my problem so give me best idea.
Nov 28 '07 #4
vaskar
5
int.parse() has overloads that might be able to help you with a unicode string?
Hi Plater


I have done as per you say but this also throw exception:
[code=vbnet]
Dim a as string=Integer.Parse(me.textbox1.text)
[code]
Above statement throw exception "Input string was not in correct format" Format Exception was unhandled

if you have any idea to convert string to integer but the string is in numeric type unicode.

thank you
Nov 28 '07 #5
mzmishra
390 Expert 256MB
try this way
Expand|Select|Wrap|Line Numbers
  1. Dim myBytes As Byte() = System.Text.Encoding.Unicode.GetBytes(textbox1.text)
  2.  
  3. Dim myChars as Char() = System.Text.Encoding.Unicode.GetChars(myBytes)
  4.         Dim myString as String = New String(myChars)

Then convert the string to integer
Nov 28 '07 #6
vaskar
5
try this way
Dim myBytes As Byte() = System.Text.Encoding.Unicode.GetBytes(textbox1.tex t)

Dim myChars as Char() = System.Text.Encoding.Unicode.GetChars(myBytes)
Dim myString as String = New String(myChars)


Then convert the string to integer
Thank You mzmishra
I will try it.
Nov 28 '07 #7
vaskar
5
try this way
Dim myBytes As Byte() = System.Text.Encoding.Unicode.GetBytes(textbox1.tex t)

Dim myChars as Char() = System.Text.Encoding.Unicode.GetChars(myBytes)
Dim myString as String = New String(myChars)


Then convert the string to integer
mzmishra

I had try as per you say.
when I convert MyString to integer Exception arises
that is "Input String was not in correct format" but the string which I press is string representation of numeric type of unicode that is 1 in US-eng and "१" in Nepali Unicode.

my line of code is

Dim myNum as Integer =Integer.parse(myString)

If you have any idea. I will be thanks for your help.
Nov 29 '07 #8
mzmishra
390 Expert 256MB
Hmm.
Not sure then.Probably someone else can give some idea
Nov 30 '07 #9
Plater
7,872 Expert 4TB
If I had to guess, I would think you would need to use the overloads for int.parse() that use the NumberFormatInfo object.
It can be assigned a culture.
You may also need to do things like allow decimal and thousands seperators.

What is the string you are trying to conver to integer?
Even as a unicode string, they still need to represent numbers, so random symbols won't work.

int.parse("123jjk"); will throw the same error, regardless of being a unicode or ascii string.
Nov 30 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Joebloggs | last post by:
Hi I am trying to do an ldap lookup. I can pick up the domain name in the standard format DOMAIN\USERNAME. The problem is the company I work for expects the query in the format DOMAIN:USERNAME....
10
by: Nikolay Petrov | last post by:
How can I convert DOS cyrillic text to Unicode
20
by: Jason Dravet | last post by:
Some time ago I wrote an application that controls the projectors in our classrooms(turn on, turn off, and volume control). This application is written in VB.net 2003. It was working perfectly...
2
by: Alex Guryanow | last post by:
Hi, I have windows app written in Borland C++ Builder 5.0. Using ODBC driver windows app connects to database on linux server. Database is created with UNICODE encoding. When pg-server is...
5
by: Allerdyce.John | last post by:
Do I need to convert string to integer in python? or it will do it for me (since dynamic type)? In my python script, I have this line: x /= 10; when i run it, I get this error: TypeError:...
8
by: csanjith | last post by:
Hi, i have a situaion where i need to convert the characters entered in an text field to upper case using C. The configuration id utf8 environment in which user can enter any character (single ,...
2
by: kath | last post by:
Hi, 38938.0 <type 'unicode'> Traceback (most recent call last): File "D:\Python23\Testing area\Python and Excel\xlrdRead.py", line 30, in ?...
0
by: phqu88 | last post by:
I have 2 objects, 1 that is essentially a parent object and another that is a child object. In the parent object (Purchase_order) very little visible data is stored but in the child object (Poline) a...
4
by: SAL | last post by:
Hello, at our company we have two different web development platforms, ASP.NET and ColdFusion. We are trying to merge security between the platforms to provide a security blanket, so-to-speak,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.