Solved

add punctuation like comma into a listbox item

Posted on 2000-05-18
12
248 Views
Last Modified: 2008-02-26
how can i add a string including punctuations like [,][;] into a listbox
while the listbox's rowsource type is set to "valuelist"
0
Comment
Question by:mhsun
  • 4
  • 3
  • 2
  • +2
12 Comments
 
LVL 5

Expert Comment

by:TheMek
ID: 2824600
Use quotes (") to surround the strings containing the (') or (;). For example set the RowSource to:
"First;item";"Second;item"
This will show like:
First;Item
Second;Item

This should help you out ;-)
Greetings,
    Erwin
0
 

Expert Comment

by:DZ
ID: 2824601
hi
you just have to put in the double quote eg: "banana;";"watermelon,"; in the row source...the result should be like this:
banana;
watermelon,
 
0
 
LVL 5

Expert Comment

by:TheMek
ID: 2824638
Hi DZ,

that was what I already said ;-) And in this topic area it is common to not post an answer to a question, but place your answer as a comment.
This way the question is not locked for other users, so that other people can comment too and give a broader view of the problem. The person that asked the question can then pick the answer he thinks helped him most with the problem.
Greetings,
   Erwin
0
 

Expert Comment

by:DZ
ID: 2824736
i'm sorry... i'm a new comer
i'm really sorry...

regards
DZ
0
 
LVL 5

Expert Comment

by:TheMek
ID: 2824756
No problem ;-) I did it the first time too, there's no way you can know until someone tells you.

Greetings,
   Erwin
0
 
LVL 7

Expert Comment

by:Believer
ID: 2826274
DZ... You need to select the option at the bottom of the Q to change your proposed answer to a comment...
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 9

Expert Comment

by:BrianWren
ID: 2826585
DZ...  If you wouldn't mind...
0
 

Author Comment

by:mhsun
ID: 2828593
sorry, what i meant was to populate a list box by using a string variable during running time while this string variable has punctuation inside,
For example:
the RowSourceType of listbox1 is set to
"Table/Query" and the items of it include punctuation.
and I want to copy an item from listbox1 to listbox2
of which RowSourceType is set to "ValueList"

my Code is like this    
For i = 0 To Listbox1.listcount- 1
        For j = 0 To 2
        ItemList = ItemList & _    Me.Listbox1.Column(j, i) & ";"
       
        Next j
Next i
    Me.listbox2.RowSource = ItemList

So, my question is what will happen if
items in listbox1 have punctuation.


Thank you for your response

0
 
LVL 5

Accepted Solution

by:
TheMek earned 50 total points
ID: 2832170
Ah, I see...try surrounding every entry with double quotes (CHR$(34)). Like this:
For i = 0 To Listbox1.listcount- 1
        For j = 0 To 2
        ItemList = ItemList & _     CHR$(34) & Me.Listbox1.Column(j, i) & CHR$(34) &  ";"
         
        Next j
Next i
    Me.listbox2.RowSource = ItemList

Greetings,
    Erwin
0
 
LVL 9

Expert Comment

by:BrianWren
ID: 2833797
Or you can double up quote inside a string assignment to produce a single quote in the resultant string:

For i = 0 To Listbox1.listcount- 1
        For j = 0 To 2
             ItemList = ItemList & """" & Me.Listbox1.Column(j, i) & """;"
        Next j
Next i
   
Me.listbox2.RowSource = ItemList

Brian
0
 

Author Comment

by:mhsun
ID: 2835531
Thank you very much for your answer, but both of the two solutions couldn't
solve my problem, below is my function
for moving one item to another, the problem is punctuation can't be included.
kindly advise me.

Function Move_Item(ctlSource As Control, strSource As String, ctlDestination As Control, strDest As String) As Integer
    Dim intCurrentRow As Integer
   
    Dim intCount As Integer
    Dim i As Integer
    Dim j As Integer
   
   
'------------Copy item selected from source list to dest list-----
    For intCurrentRow = 0 To ctlSource.ListCount - 1
        If ctlSource.Selected(intCurrentRow) Then
            For i = 0 To 2
            strDest = strDest & ctlSource.Column(i, _
                 intCurrentRow) & ";"
            Next i
        End If
    Next intCurrentRow
    ' Reset destination control's RowSource property.
    ctlDestination.RowSource = ""
    ctlDestination.RowSource = strDest
   
'------------Remove item selected form source list-------------
    strSource = "" 'Clear Source Content!!!
    For intCount = 0 To ctlSource.ListCount - 1
        If Not ctlSource.Selected(intCount) Then
            For j = 0 To 2
            strSource = strSource & CHR$(34)& ctlSource.Column(j, intCount) & CHR$(34)& ";"
            Next j
        End If
       
    Next intCount
    ctlSource.RowSource = ""
    ctlSource.RowSource = strSource

End Function
0
 

Author Comment

by:mhsun
ID: 2835564
I am sorry for the above comment, it works, it didn't work just because i forgot to update another function using this way, thank you very much theMek and brianWren, its really a great help for me. actually i already tried this way in my move_item function, but same problem:i forgot to change another function, since i don't have too much experience, so i thought this way doesn't work. Thanks again,DZ also.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now