Converting string to an integer

I have an page in which a user inputs a SSN in the proper format 555-55-5555 I want to put tha into an Interger field in the sql database. How to I convert my value in the textbox to an interger that the database will accept.
12/2/2003 4:38:19 PM 91979 articles. 4 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 38
Get it on Google Play
Get it on Apple App Store

Are these seperate text inputs like so:

555 = first text box
55 = second
5555 = third
IF so you can tie them together with the string builder class and then convert them to an int with "int.Parse()", post your code and I can better show you.

Sam Cromer
Senior .NET Developer
12/2/2003 5:05:06 PM
First you have to strip the "-" s.

Then concatenate the individual parts into a string...
type cast the string into an integer...
save it into database...

Dim aSSN as String
Dim aSSNParts as String()
Dim aSSNToDB as Integer
aSSN = txtSSN.Value
aSSNParts = aSSN.Split("-")
aSSN = aSSNParts(0) + aSSNParts(1) + aSSNParts(2)
aSSNToDB = CType(aSSN,Integer)

now you can insert the aSSNToDB field into your database....
Hey! It compiles! Ship it!


Venugopal Mallarapu.

Visit : My Blog
12/2/2003 5:14:56 PM

Similar Artilces:

Is there any function to convert string to integer in
Is there any function to convert string to integer in thank you very much.As Heinlein said "specialization is for insects" explore beyond the universe. Hi There, You can do this Dim Val as String = "50" Dim i As Integer = Convert.ToInt32(Val)DC517Don't forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point and marks your thread as Resolved. thank you very much dennisAs Heinlein said "specialization is for insects" explore beyond the universe. Hi There, No problem, always welcome...

converting string to integer, subtracting strings.
Hi,  I have a textbox into which the user will enter a number I then have button that when the user clicks, the number taken from the textbox will be subtracted by one or more(depending on the users situation) and displayed in a label.   The problem i am having at the moment is that when i attempt to do this an error comes up saying that "the operator '-' cannot be used with string or int". String Score1 = txtScore1.Text: String netScore1;   netScore1 = Score1 - 1; lblNetScore1.Text = netScore1;   I have ...

VS.NET 2005 is ignoring in web.config strict="true". I get no error when I try this: Dim x As Integer = "string"
Hello,I have this in my VS.NET 2005 web.config <compilation debug="true" strict="true" explicit="true">When I do this in my vb code:Dim x As Integer = "string"I get no error. When I hit compilation I also get no error. What am I doing wrong?Thanks for helping!Regards,J. Bauer It's a bug of some sort See this response by Scott Guthrie Unfortunately we don’t have a GUI based way to configure this. L It is something we will make sure gets added back in, though, with the next...

Getting error while converting string to double: Input string was not in correct format
Select Case LocalMeasuringUnitText Case "Currency" 'do the conversion hereDim ConversionRate As Double = GetConversionRate(_LanguageID)   Dim UKValue As Double 'String.Format("{0:c}", SelectedRow(rowloop).Item("TransData").ToString()) Dim varValue As Object = NothingDim Stringvalue As Object = SelectedRow(rowloop).Item("TransData").ToString.Trim 'varValue = Double.TryParse(Stringvalue, varValue) 'CType(Stringvalue, System.Double) 'UKValue = Convert.ToDouble(Stringvalue) / GetConversionRate(ConfigurationManager.AppS...

Converting Strings To Integers
I have a number in a text field "0003" that I need to convert to 3(the number) to pass onto a stored procedure, but I'm having difficulty with which command to convert it properly I keep getting errors. Any Suggestions VB or C# VB: Dim i As Integer = Convert.ToInt32(stringvar) C#: int i = Convert.ToInt32(stringvar); C# Only: (int32) stringvar; VB Only: CType(stringvar, System.Int32) Anyway will work, they differ only in explicit or implicit conversion methods.MCSD / MCAD / MCP Int.Parse(string) should work too. Yes, actually, you must either use the...

Convert string to integer
How I can transform string type var to var with integer type? .... var id = file_stream.readline(); .... .... id = id + 1; - this command just add new symbol in my case... Welcome to the ASP.NET Forums, Sapfir. Try: // declare id as an integer int id = 0; // convert from string to int, and assign to id // this may fail, which is why we must place the conversion inside a Try/Catch block try { id = int.Parse( file_stream.readline() ); } catch { // handle this if you care to, // or a...

Converting classic to .NET 2 code, and .NET gets an error back from ADS?
 For future-proofing, our Internal Phone Directory is being moved onto our AD servers, and obviously we're using LDAP for queries.To get the phoneboook queries working, I adapted the current classic ASP code to use LDAP, and that works fine. However, we're wanting to move these pages to .NET, and that's where the problem comes in. Using the same basic logic from the Classic code (90% of its unchanged) to produce an LDAP query, I get the error  155 Unknown error (0x80005000)This is using the same website, and so the same credentials  - unless aspx pages run und...

How to convert a String to an integer?
Hello, How to convert a string which has only numbers to an integer. I know the other way around but this one i don't know. Thanks, Miguel Here is a simple example:    Dim firstInt As Integer = Int32.Parse("13")    Dim secondInt As Integer = Int32.Parse("12")    Dim thirdInt As Integer = firstInt + secondIntThe variable thirdInt will have the value 25.Alister...

How do I convert a string into an integer?
How do I convert a string into an integer, I have the following problem: DropDownList1.Items.Add(objDataReader1.GetString(1) & " " & objDataReader1.GetString(2)) DropDownList1.DataValueField = objDataReader1.Getint32(0) this is the number of a record(unique) ''''''''''''''''' overzichttoe(txtdatum.text, 1, 1,DropDownlist1.selectedItem.Value ) I have to convert this "DropDownlist1.selectedItem.Value" to an integer THX a lot!!!!!!!!!!! c You can write Convert.ToInteger(DropDownlist1.selectedItem.Value)Sushila Bowalekar PatelVisual ASP/AS...

Converting string to integer
 I have a textbox which the user will enter a number into.  I then have a label control which will perform a maths operation and write out the resulting answer; atleast this is whant I want anyway however this is not happening.The code I have so far is   1 Protected Sub btnWork_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnWork.Click2 3 Dim Work As Integer4 Work = txtWorkSet5 lblS.Text = ("Work * 0.4" & " kg").ToString6 7 End Sub  I get an...

Getting Start With .net
hi i'm intersted to learn (vb or delphi) . i programming with delphi6 but i'd like to tp know something about programming in internet specially with .net . i hear about with delphi 7 that i can programming with delphi in .net .... is it right ? what 's our opinian about it ? and better to learn Vb.Net or continu with delphi(or thanks. Ali Darabian I think there is some support for Delphi in .Net. However, you will find much more support from the user community if you choose a more popular language such as VB.Net or C#. Since your al...

how to get start with .NET
the net help people installed  to my desktop 1-microsoft visual studio .NET enterprise developer 2003 2-microsoft .NET framework 1.1 what else do i need ...???  and how can i try with some simple code in VS.Net and run it to see wat happen...????? please help If you want to develope web applications, then you'll also need IIS on your PC.  That'll require XP-Professional or Windows 2000/2003, but XP-Home edition won't allow IIS installation. As for how to get started, you can search the web for some tutorials or buy a good book on VS.  The topic is way too vast to...

used a to converter and am now getting a syntax error.
ok I used a cool utility at to convert some to and it spit out a bunch of code which almost works but I am getting a syntax error on this line Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) I tried it that way and also like Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) but either way gave the same error Compiler Error Message: BC30035: Syntax error. Source Error: Line 26: Line ...

Converting a string to an integer
I have an identification card that contains a group of characters within a bar code. I need to extract the first 6 characters and convert them to a Social Security Account Number (SSAN).  In cold fusion I use InputBaseN(stringvalue, 32) and all is well.  I am having difficulty achieving the same result in VB. Any help or suggestion would be appreciated since I am new to all this. <JP> you can do a substring. perhaps something like : convert.toint16(stringvalue.substring(1,6))***********************Dinakar NethiLife is short. Enjoy it.*********************** I know the 6...

Web resources about - Converting string to an integer -

PastBook’s Integration Eases Process Of Converting Facebook Content To Books
PastBook , one of several companies that allow Facebook users to publish their content on the social network in actual books , announced the ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Zwartz Laminating-Converting B.V. on the App Store on iTunes
Get Zwartz Laminating-Converting B.V. on the App Store. See screenshots and ratings, and read customer reviews.

"Occupier" Thanked Former Soviet Citizen for "Converting" Him to Capitalism, Pro-Israel, Pro-USA - YouTube ...
May Day Demonstration on Union Square in New York City Zionism & Birth of Modern Israel in 1948: Former Soviet Citizen Pays Tribute to Ben-Gurion ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Converting Churches Into Homes Is The Latest Hollywood Trend
You don't have to be a believer to be moved by the beauty of a church.

Resources last updated: 12/16/2015 12:34:12 PM