How do I do that? Turning the layout from the customerID-number "10205" into looking like "10 205"? I've just incresed it from four digits to five, and it looks like this: lsvItem.SubItems(1) = Right("0000" & CStr(rs!customerID), 5), but how do I affect the layout?
3 1534
How do I do that? Turning the layout from the customerID-number "10205" into looking like "10 205"? I've just incresed it from four digits to five, and it looks like this: lsvItem.SubItems(1) = Right("0000" & CStr(rs!customerID), 5), but how do I affect the layout?
One fairly simple way would be... - strID = Right("0000" & CStr(rs!customerID), 5)
-
lsvItem.SubItems(1) = Left(strID,2) & " " & mid(strID,3)
You could probably do it more simply using the Format() function, I'm just too lazy to look it up right now.
The precise method would depend a bit on the format of the customerID field - is it text or numeric?
I think you mean you want to put a space after every third digit starting from the right to separate hundreds, thousands, millions, hundred-millions etc...?
Example: 99999999 -> 99 999 999
If so, I'll try to make a function for you...
Here we are! :D Tested and working: -
Public Function NumberSeparate(NumberToSeparate, Optional SeparatingChar As String = " ") As String
-
'
-
'NumberToSeparate - The original number
-
'SeparatingChar - What to separate the digits with.
-
' Usually a comma, space, or dot.
-
' By default it is a space.
-
'
-
'Gives back a string with the number nicely separated at every
-
'third digit.
-
-
-
Dim CurrentDigit As Byte
-
Dim CurrentBackward As Integer
-
-
CurrentDigit = 0
-
NumberSeparate = Str(NumberToSeparate)
-
-
For CurrentBackward = Len(NumberSeparate) To 1 Step -1
-
-
CurrentDigit = CurrentDigit + 1
-
If CurrentDigit = 3 Then
-
-
NumberSeparate = Mid(NumberSeparate, 1, CurrentBackward - 1) + SeparatingChar + Mid(NumberSeparate, CurrentBackward, Len(NumberSeparate) - (CurrentBackward - 1))
-
CurrentDigit = 0
-
-
End If
-
-
Next CurrentBackward
-
-
'Remove any accidental separating chars on the left
-
'before any digits!
-
While Mid(NumberSeparate, 1, 1) = SeparatingChar
-
NumberSeparate = Mid(NumberSeparate, 2, Len(NumberSeparate) - 1)
-
Wend
-
-
-
End Function
-
Thanks for that.
I don't mean to rain on your parade, but it seems to me you could achieve much the same end with one statement... - Public Function NumberSeparate(NumberToSeparate, Optional SeparatingChar As String = " ") As String
-
' NumberToSeparate - The original number
-
' SeparatingChar - What to separate the digits with.
-
' Usually a comma, space, or dot.
-
' By default it is a space.
-
' Gives back a string with the number nicely separated at every
-
' third digit.
-
-
NumberSeparate = Replace(Format(NumberToPad, "#,###"), ",", SeparatingChar)
-
-
End Function
(Sorry, but since I recently discovered the Split and Replace functions I've been having great fun finding uses for them.)
Oh, and this might need adjustment to handle different regional number-formatting settings.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: lime |
last post by:
I have addressed most of the issues listed in the responses to my last post
"Critique CSS layout (1st go - fingers crossed)". I'm rapt with the progress
I have made, thanks to all for your past...
|
by: Diane Wilson |
last post by:
I'm trying (once again) to figure out how to make a robust
CSS layout style that can replace tables. I'd like to be able
to do a basic two-column layout, with a one-column header,
a two column...
|
by: Deena |
last post by:
Hi
Windows forms layout is turning to be a nightmare. I add my controls to a
form and then save it and then it just get's all messed up. I'm using
inheritance if this makes any difference. Also...
|
by: et |
last post by:
How do I get Visual Studio to quit modifying the layout of my code? In
Tools, Options, Text Editor, All Languages, Tabs, I have set to None.
In HTML/XML, I have tabs set to none; all automatic...
|
by: Magnus Warker |
last post by:
Hi group!
I know that HTML output is not as predictable as sometimes desired, but let
me ask a question.
The following HTML code produces a rectangle that covers the entire client
area of a...
| |
by: =?Utf-8?B?QnJldA==?= |
last post by:
I have a standard Form View bound to a SQL Data Source with about 30 fields
and it works well and fine.
However I want to change the layout from the standard Vertical View of form
to
a more...
|
by: Jlcarroll |
last post by:
Hi,
I am building a web page.and have a simple javascript menu... I call
the javascript menu within a div block that my print sytlesheet has
set as a display: none;, well all the content in that...
|
by: Nik Coughlin |
last post by:
I am halfway through writing a tutorial on image slicing for fluid CSS
layouts, I would love some feedback on what I've done up until this point:
http://nrkn.com/index.html
I am still writing...
|
by: brave1979 |
last post by:
Please check out my javascript library that allows you to create any
layout for your web page, nested as deep as you like, adjusting to
width and height of a browser window. You just describe it in...
|
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,...
|
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...
| |
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
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: 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...
|
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 ...
| |
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...
| |