473,583 Members | 2,875 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how do i format the text in my textbox

1 New Member
i have a set of phone numbers loaded into my text-box and i want to format the record such that each phone number of 11 digits is separated by a comma. that is after every 11 digits a comma will be automatically placed. please what code do i use in VB.net
Feb 25 '15 #1
2 1913
lillyehrhart
48 New Member
try this

Format(TextBoxN ame.Text, "0000000000 0,")
Sep 8 '15 #2
Luk3r
300 Contributor
Expand|Select|Wrap|Line Numbers
  1.         'Get the length of characters in the text box
  2.         Dim textBoxLength As Integer = TextBox1.Text.Length
  3.  
  4.         'Format the textbox character length by dividing by 11 (phone number length) and subtracting 1 (total number of commas to add)
  5.         Dim textLength As Integer = textBoxLength / 11 - 1
  6.  
  7.         'Make i an integer which is equal to the textLength variable.  This is not necessary, just pretty
  8.         Dim i As Integer = textLength
  9.  
  10.         'Loop in reverse order, inserting a comma every 11th character
  11.         'We are looping backwards since the length of the textbox text changes with every insertion
  12.         Do Until i = 0
  13.             TextBox1.Text = TextBox1.Text.Insert(11 * i, ",")
  14.             i = i - 1
  15.         Loop
  16.  
Sep 9 '15 #3

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

Similar topics

1
2746
by: Newgene | last post by:
Hi, group, I have python2.3 installed on win2k. I noticed that when I open a dos format text file (eol is '\r\n'), readline() always returns a line ending with '\n' only, not '\r\n'. While I read the same file on unix, it returns a line ending with '\r\n' correctly. This makes me difficult to determine the format of a text file, dos or unix....
2
5645
by: ezelasky | last post by:
We are using the bcp utility (via APIs) to export data from a SQL table in a fixed format text file. BCP is inserting spaces for a field if the field contains a NULL. This is fine with us except at the end of the line, there are no spaces for that field just the end-of-row terminator prematurely, so it looks like that field is not present...
6
7718
by: dyw55a | last post by:
How to implement mm/dd/yyyy format for textbox? I have text box with format mm/dd/yyyy. Now I want the cursor i generated whenever user highlight this textbox and whatever user inpu replace one of char in "mm/dd/yyyy" one at a time. I will be appreciated if anyone could give me some idea to implemen this through JavaScript. thanks,
11
2108
by: Stan Sainte-Rose | last post by:
Hi, How to format a textbox to force the user to write only digits like 127-343 ? Thx Stan
2
1289
by: Jimmy | last post by:
How can i format text, so that user input such as, 01062004 would be formatted as 01/06/2004. I've tried several user-defined number and date formats, but I seem to be missing something. Thank you.
13
9378
by: Agnes | last post by:
I know someone post the solution before, but I didn't keep in mind . So I am sorry to ask the same question again I had bind a datatime to the textbox name txtInvoice I want it displayed in dd-mm-yyyy I try txtInvoice.txt = Format(txtInvoice.txt,"dd-mm-yyyy"), its return error. Anyone know to do it ?? Thanks
1
1537
by: cr113 | last post by:
How do I format text in datagrid column? I have a column of currency values and I want them all to display with 2 decimal points (XXX.XX). I figured out how to set the width and alignment as follows: DataGrid1.TableStyles(0).GridColumnStyles(0).Width = 140 DataGrid1.TableStyles(0).GridColumnStyles(1).Width = 125...
3
1675
by: dennist685 | last post by:
Format text as a heading I'm progressing through a walkthrough on DetailsView control Early on it says Type Edit Employees, select the text, and then format the text as a heading. I clicked format, then styles, but nowhere found how to make selected text a heading.
13
3230
by: Neil Cerutti | last post by:
Many of the file formats I have to work with are so-called fixed-format records, where every line in the file is a record, and every field in a record takes up a specific amount of space. For example, one of my older Python programs contains the following to create a fixed-format text record for a batch of new students: new =...
3
5975
by: Joe | last post by:
Hi, I am storing a field in SQL Server with a datatype of money. When I pull that field back into my VB.NET client program, I put it into a typed dataset with a field type of System.Decimal. When it displays in the textbox that I have tied to the dataset, it appears as 4000.0000 but I want it to appear as $4,000.00 How can I achieve...
0
7888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7811
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8314
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8185
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5689
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3811
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.