Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 8th, 2003, 03:44 AM
Ben Ben is offline
Authorized User
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default String Manipulation

I have a string which is in the following format;

"1,450,2,300,3,450,4,50"

The string is created through a custom VB function and populates a query. I have managed to manipulate the string on a report via another custom VB function so it then looks like this;

"Code1 450 Code2 300 Code3 450 Code4 50"

However I want each code to be on a separate line - so it appears like this:

Code1 450
Code2 300
Code3 450
Code4 50

This is where I get stuck - has anyone any ideas?

(I don't think I can force the values through a number of text boxes as the number of codes could change...)

Thanks
Ben
 
Old July 8th, 2003, 05:34 AM
Authorized User
 
Join Date: Jul 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alex_read
Default

Try taking a look at the Split function built into vb, from your MSDN helpfiles...
Code:
Private Sub Form_Load()

    Dim strTemp As String
    Dim straryTemp() As String
    Dim intLoopCounter As Integer

    strTemp = "1,450,2,300,3,450,4,50"
    straryTemp = Split(strTemp, ",")
    strTemp = ""

    For intLoopCounter = 0 To UBound(straryTemp)
        strTemp = strTemp & "Code" & straryTemp(intLoopCounter)
        strTemp = strTemp & " " & straryTemp(intLoopCounter + 1)
        strTemp = strTemp & vbCrLf

        intLoopCounter = intLoopCounter + 1
    Next intLoopCounter

    Text1.Text = Text1.Text & strTemp
End Sub
 
Old July 8th, 2003, 05:53 AM
Ben Ben is offline
Authorized User
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Alex this is great





Similar Threads
Thread Thread Starter Forum Replies Last Post
String manipulation Franco1 Visual Basic 2005 Basics 1 July 16th, 2008 12:53 PM
String manipulation john316 SQL Language 1 October 1st, 2007 04:24 PM
String manipulation pcase XSLT 5 June 14th, 2007 10:32 AM
String manipulation YoungLuke C# 4 May 4th, 2007 01:46 AM
String Manipulation twsinc Access 3 February 23rd, 2004 09:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.