Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 May 6th, 2007, 11:14 PM
Authorized User
 
Join Date: May 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jd_erd Send a message via AIM to jd_erd Send a message via MSN to jd_erd Send a message via Yahoo to jd_erd
Default using the split function

I was wondering if someone could tell me if there is a way to use the split function to split a string up and then give me the total number of substrings and store them so I may trim them to create load numbers for example

Post Office
and then
split it so it is
Post Office and I would want to trim it to

PO

I figured once I split them I could use the left function to trim them to the first character

any help would be greatly appreciated





jd erd
__________________
jd erd
 
Old May 7th, 2007, 07:15 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

When you use the Split() function, you put the results in an array, and then use the Left(Array(i), 1) to get the first character.

Your code looks like:

Dim POArray As Variant

sString = "Post Office" 'for example

ReDim POArray(0)

POArray = Split(sString, " ") 'This splits the string based on a space

sNewString = ""
i = 0

Do Until i = UBound(POArray) + 1
   sNewString = sNewString & Left(POArray(i), 1)
   i = i + 1
Loop

This will yield "PO" from "Post Office"

Did that help any?


mmcdonal
 
Old May 7th, 2007, 09:59 PM
Authorized User
 
Join Date: May 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jd_erd Send a message via AIM to jd_erd Send a message via MSN to jd_erd Send a message via Yahoo to jd_erd
Default

thanks you so much that helped me do exactly what I wanted

jd erd





Similar Threads
Thread Thread Starter Forum Replies Last Post
split function equivalent asmotritsky SQL Server 2000 4 January 5th, 2009 08:40 AM
Split function using ASp *Urgent* deean Classic ASP XML 5 June 20th, 2008 05:42 PM
split function MunishBhatia ASP.NET 2.0 Professional 4 May 1st, 2007 10:05 AM
using 'Split' function p_gauri7 Crystal Reports 0 March 11th, 2005 01:02 PM
Split function Beulah ASP.NET 1.0 and 1.1 Basics 1 September 12th, 2003 09:14 AM





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