Deal all,
I have a textbox that I want to apply some formatting to the text:
I know that if the textbox contains only numbers, by selecting "Standard" format, I can have the thousands seperator: 1,245,000
but the textbox that I have includes both text and number. for example:
Hello 1245000
I want to apply the thousand seperator to it:
Hello 1,245,000
How? :(
8 1779
Text parsing is a bit of a pain, but if you have to do it, try this. Split() the text into separate words.
Check whether each word is a number with IsNumeric().
If the word is numeric, use FormatNumber() with the GroupDigits option. Concatenate each of the words together again for the result.
NeoPa 32,556
Expert Mod 16PB
Good idea.
The Join() function can also be used to put the various elements back together. It is effectively the opposite of Split(), even with the same optional separator parameter.
@Alireza355
Is the Format always TEXT & SPACE & NUMBER?
@Alireza355
To expand on ChipR's explanation in Post #2, and assuming components are delimited by a Space (" ") then: - Public Function fFormatString(strSomeString As String) As String
-
Dim varSplit As Variant
-
Dim strBuild As String
-
Dim intCounter As Integer
-
-
If Len(strSomeString) = 0 Then Exit Function
-
-
varSplit = Split(strSomeString, " ")
-
-
For intCounter = 0 To UBound(varSplit)
-
If IsNumeric(varSplit(intCounter)) Then
-
strBuild = strBuild & " " & FormatNumber(varSplit(intCounter), 0)
-
Else
-
strBuild = strBuild & " " & varSplit(intCounter)
-
End If
-
Next
-
-
fFormatString = Trim$(strBuild)
-
End Function
- ? fFormatString("Help 12345 6792 me 656565656 Rhonda 989776 4434434 A B C 456") produces ==>
Help 12,345 6,792 me 656,565,656 Rhonda 989,776 4,434,434 A B C 456
Dear Adezii,
Thank you so much for your kind help.
Please tell me how I can use the code you have given. (Where to put it and what to change, and how to make it run)
And I also thought this might be useful: the textbox I am trying to format is a calculated textbox.
=IIf([text51]=[text49],0,IIf([text51]>[text49],[text51]-[text49] & " (Credit)",[text49]-[text51] & " (Debit)"))
Thanx a lot.
@Alireza355 - Copy and Paste the entire Function Definition into the General Declarations Section of a Standard Code Module, the Function will then be contained within the Module and can be called from anywhere within the Application since it is Public.
- Create an Unbound Text Box, and set its Control Source to:
- =fFormatString(IIf([text51] = [text49], 0, IIf([text51] > [text49], [text51] - [text49] & _
-
" (Credit)", [text49] - [text51] & " (Debit)")))
WOW!!!!!!!!!!!!!!!!
Thanx a loooooooooooooooooooooooooooooooooooooooooot
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jose Gonzalez |
last post by:
How to apply a numeric format to a textbox using xhtml? I know you have to
use the "-wap-input-format" style tag in css. I can get this to work in a
regular xhtml page, however, I've been...
|
by: I am Sam |
last post by:
I have a DataGrid that is passing information to a stored procedure properly
but the parameters aren't being casted properly. I was woundering if anyone
can tell me how I should properly cast the...
|
by: Rich |
last post by:
Hello,
I have some datefields in a dataset (ds1). I bind some
textbox controls on a windows form to these date fields in
ds1, but I only want to see 01/01/2004 instead of 1/1/2004
8:00:00 AM. ...
|
by: MLH |
last post by:
I use A97. I've gotten used to reading values from textbox controls
on forms, I've come to rely on it pretty heavily. My habit spills over
into reports. I'm uncertain whether I can reliably read...
|
by: Adam Honek |
last post by:
I have a form.
It has serveral text boxes for user data entry.
I could of course write code to check if each is empty before proceeding to
save this data to a file.
Is there any global way...
|
by: Anonieko |
last post by:
Are there any javascript codes there?
Answer: Yes
On the PageLoad event call InitialClientControsl as follows
/// <summary>
/// This will add client-side event handlers for most of the...
|
by: nussu |
last post by:
Hi,
A textbox has to accept only numeric values by using validation controls in .net 2.0
Plz help me ...
Regards,
Nussu
|
by: JFKJr |
last post by:
Hello everyone, the following Access VBA code opens an excel file and creates textboxes in a given range of cells dynamically. The code attaches "MouseUP" and "Exit" events to the textboxes (using...
|
by: =?Utf-8?B?dHBhcmtzNjk=?= |
last post by:
OK I have some Chinese text in sql server column that looks like this:
12大专题调研破解广东科学发展难题
This is unicode? Anyway, I put this data into a text area like this:...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shllpp 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |