Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To 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
  #1 (permalink)  
Old November 8th, 2004, 02:40 PM
Jen Jen is offline
Registered User
Join Date: Nov 2004
Location: London, Ontario, Canada.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default JOIN an array

Hi all

I need to take all instances of sub-item descriptions and pop them into another textbox as a concatenated string - so basically I am trying to define the sub-item descriptions as an array and then JOIN and TRIM them so that I end up with a string made up of all of these descriptions. I get a type mismatch error at the moment when I try to define Descrip as an array equal to the description field and when I take that line out (see below), I get a null string because it isn't pulling from anything. So basically my questions is: what am I doing wrong? And how do I join an array of strings into one result string?

This is my code:

Dim CountSub As Long
CountSub = Forms!frmPricingSheet!frmPricingsubform![SubItemCount]
Dim Descrip() As String
Descrip = Forms!frmPricingSheet!frmPricingsubform![Description] (Error here)

Dim CompDesc As String
ReDim Preserve Descrip(1 To CountSub) As String

CompDesc = ""
    For CountSub = 1 To UBound(Descrip)
        If Descrip(CountSub) <> "" Then
        If CompDesc = "" Then CompDesc = CompDesc & " "
        CompDesc = CompDesc & Trim(Descrip(CountSub))
    End If

Forms!frmPricingSheet![Description].Value = CompDesc


  #2 (permalink)  
Old November 9th, 2004, 05:38 AM
Friend of Wrox
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp

I could not understand your problem fully. What do you mean by "sub-item" ? May I know what is the object frmPricingsubform![Description] ? Is it a text box ? Are there a number of text boxes of this name in a form ?

I think you may have to use a control array of textboxes of same name. You can then join the texts as below.

strFinalString=Description(0).Text & Description(1).Text & .... & Description(n).Text

You have to have the number of textboxes in a variable say iNumTextboxes. Then the following script will do it.

For iLoop=0 to iNumTextboxes-1
    strFinalString=strFinalString & Description(iLoop).Text
  #3 (permalink)  
Old December 2nd, 2004, 09:58 AM
Aal Aal is offline
Authorized User
Join Date: Oct 2004
Location: , , .
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Jen . . .
Have u ever used this methode :

Dim mArr as Variant

    mArr = array(String1,String2,String3. . .)
    'this methode join the string automatically and read it as array
    '//now loops the mArr variable ( This methode almost similar with SPLIT methode. In this case the delimiter is " coma " ( the fixed delimeter ).

    For i = 1 to UBound(mArr)
        'Put the result in a Listbox for example
        list1.Additem mArr(i - 1)

Hope this, can help u to solve your problems . . .
and a, do you have some information about making Autorun Setup from CD's ?
However . . .have a nice coding Jen !!!

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
error when sorting an Array of Array nancy VBScript 2 February 17th, 2005 12:57 PM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
Oracle 8i inner join and left join problem puteri_84 Oracle 2 August 19th, 2004 07:14 AM

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