473,401 Members | 2,068 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,401 software developers and data experts.

Adding * to the left of a field to fill a certain number of characters

46
I am working out my payroll system and would like * to the left of the field that has the check amount in "words"

example:
(Currently Showing)
one thousand and five hundred dollar and 12 cents
(Would like it to show)
one thousand and five hundred dollar and 12 cents*********

Another example
(Currently Showing)
ten dollars
(Would like it to show)
ten dollars******************************************* ***

I figured I would have to len(field) to find length of string then somehow fill it to "100" characters with * starting at left$(len(field)).

My thought process might be way off.

Thanks for your help,
Vasago
May 22 '14 #1
5 1352
jimatqsi
1,271 Expert 1GB
Vasago,
Lots of ways to solve this one. Here's one
Expand|Select|Wrap|Line Numbers
  1. strAmount = Some$InWords
  2. do while len(strAmount)<100
  3. strAmount=strAmount & "*"  ' keep adding * until 100 chars long
  4. loop
  5.  
Jim
May 22 '14 #2
zmbd
5,501 Expert Mod 4TB
yuck loop.

BTW: Title states to add to the left... the example adds to the right. (^_^)
We can fix that (^_^)

Working from your example:
open the VBA editor

<ctrl><g>
Type the following into the immediates window.

Expand|Select|Wrap|Line Numbers
  1. strz = "abcd"
  2. ?strz
  3. abcd
  4. rplz = strz & string((100-len(strz)),"*")
  5. ?rplz
  6. abcd************************************************************************************************
  7. rplz = string((100-len(strz)),"*") & strz 
  8. ?rplz
  9. ************************************************************************************************abcd
  10.  
I'll leave it for you to code.
May 22 '14 #3
NeoPa
32,556 Expert Mod 16PB
Sorry to reset your answer Jim, but I'm afraid it wasn't a good one for the question. Using the String() function as illustrated in Z's post would be the obvious and standard approach.
May 23 '14 #4
jimatqsi
1,271 Expert 1GB
Well, you win some, you lose some. I don't believe I have ever used that String function. Many thanks to ZMBD for enlightening me on that one.

Jim
May 23 '14 #5
zmbd
5,501 Expert Mod 4TB
Just swooping in before I start the long drive...

Loop or String() either IMHO either is a solution.
I remember a time when String() wasn't an option so keeping the loop in the bag-o-tricks is a good thing...


(^_^)
May 23 '14 #6

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

Similar topics

3
by: Funnyweb | last post by:
When adding a field to a table using ALTER TABLE is it possible to check if the field already exits before the ADD command is run? If so how do I do this? Thanks Hamilton
1
by: gary | last post by:
How do you add a field to the begining of the recordset. I need the new field to be the first field. Thanks
3
by: GL | last post by:
Hi, Is there a way to add a field to an existing table using a query of some sort (without needing to manually add a field to the table). I know how to do it with a make table query, but I have...
2
by: Scott | last post by:
How do I trim the left digit from a number? The user will input a number with 3 digit value and I need to trim the leftmost value from the number. A typical value might be 123.4567 and I need to...
2
by: Ron | last post by:
How can I select a certain number of characters from a string, without selecting the whole string? For example, I want the first 50 characters of a 500 character string in my database. What...
7
by: john | last post by:
I have a form with 1 table. I would like to create a field in my form that shows the number of records (of the whole table) that have one particular value. Is that possible? I fiddled with a...
6
by: Michael R | last post by:
I haven't found anything that would help me to understand the correct syntax for having a certain number of digits phone number validation rule. My input mask for this field is: \000\-0000000;;...
3
by: roondog | last post by:
I have just started learning php and mysql. I am trying to make a news page for a site where you can enter news in a form and it appears on the news page. That is done, fairly simple. I've also...
21
by: Yoni Hasid | last post by:
Hello, I am trying to match tables into a query based on 5 first characters in one field. I used expression: =left(), 5) however it does not return matched entries as I needed. Basically, I need to...
1
by: Hema Selvan | last post by:
I am new to MS Access. I have created a database. One of the field have Item number which has more than 20 digits. First i had the field with Text. I have problem as the Item number is duplicating....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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,...
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
agi2029
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 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.