473,386 Members | 1,738 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,386 software developers and data experts.

Concatenating strings

pcb
Hi All,

I have a procedure that concatenates sample numbers. The format of the
numbers are B-00001, B-00002, etc.
For example, if I have 3 sample numbers and I want to concatenate them
as follows:

('B-00001', 'B-0002', 'B-00003')

I wrote the following code:
_____________________________________

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSampleNumbers As String

Set frm = Forms!frmBlanks
Set ctl = frm!lboBlankDetails

strSampleNumbers = "("
For Each varItem In ctl.ItemsSelected
strSampleNumbers = strSampleNumbers & "', '" & ctl.ItemData(varItem)
Next varItem
strSampleNumbers = strSampleNumbers & "')"
______________________________________

However, the output is:

(', 'B-00001', 'B-0002', 'B-00003')

Can anybody help. I want to try avoiding using a "For i=0 to Count
....Next i" type structure.

Thanks!
Peter

Nov 13 '05 #1
1 1756
Braindead but effective method:

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSampleNumbers As String

Set frm = Forms!frmBlanks
Set ctl = frm!lboBlankDetails

For Each varItem In ctl.ItemsSelected
strSampleNumbers = strSampleNumbers & "', '" & ctl.ItemData(varItem)
Next varItem

strSampleNumbers = "(" & Mid$(strsamplenumbers,4) & ")"
"pcb" <br******@inspection.gc.ca> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi All,

I have a procedure that concatenates sample numbers. The format of the
numbers are B-00001, B-00002, etc.
For example, if I have 3 sample numbers and I want to concatenate them
as follows:

('B-00001', 'B-0002', 'B-00003')

I wrote the following code:
_____________________________________

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSampleNumbers As String

Set frm = Forms!frmBlanks
Set ctl = frm!lboBlankDetails

strSampleNumbers = "("
For Each varItem In ctl.ItemsSelected
strSampleNumbers = strSampleNumbers & "', '" & ctl.ItemData(varItem)
Next varItem
strSampleNumbers = strSampleNumbers & "')"
______________________________________

However, the output is:

(', 'B-00001', 'B-0002', 'B-00003')

Can anybody help. I want to try avoiding using a "For i=0 to Count
...Next i" type structure.

Thanks!
Peter

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dont bother | last post by:
Hey, I have these attributes: index which is a numerical value value vector which is a numerical float value and I want to concatenate like this:
4
by: Juan | last post by:
Does any one know if there are reported bugs when concatenating strings? When debugging each variable has the correct value but when I try to concatenate them some values are missing (I canīt see...
1
by: ebobnar | last post by:
I need to call the function LoadImage which take a LPCTSTR argument to specify the path to the image to load. However, I need to create this path dynamically from user input by concatenating...
4
by: FB's .NET Dev PC | last post by:
Interesting note, the code below as is will attempt to cast what is clearly indicated as a string into a double. This is becuase the use of + as a concatenation operator. The error message...
6
by: Hennie7863 | last post by:
Hi, I have table which has the following values : ID SEQ Text 1 1 A 2 1 B 3 2 C 4 2 D 5 2 E
4
by: lindiwemaduna | last post by:
I want to concatenate values of two text boxes into one string but these should be separated by a space in the database table. i have tried all the following but twas not successful: Dim fullName...
21
by: c | last post by:
Hi everybody. I'm working on converting a program wriiten on perl to C, and facing a problem with concatenate strings. Now here is a small program that descripe the problem, if you help me to...
10
by: Neil | last post by:
Using the MS Rich Textbox Control 6.0 in Access 2000, I need to concatenate several RTB controls into a single RTF file. Sometimes two strings will be side-by-side; other times they need to be...
3
by: Big Brother | last post by:
I've been thinking about the seemingly simple task of writing a va_arg-type function to concatenate arbitarily many strings. My first thoughts violated the following principles: 1) never...
4
by: clinisbut | last post by:
I'm not sure if this is the right group, but I didn't found any other more appropiate to post my problem. I'm trying to concatenate chars using the Glib library and I'm getting strange...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.