Results 1 to 7 of 7

Thread: [RESOLVED] Can't Assign to Array please help :((

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    21

    Resolved [RESOLVED] Can't Assign to Array please help :((

    Code:
    Private Sub Command1_Click()
    Dim a As String, i As Long
    Dim b() As String
    For i = 1 To 15
    a = "test" & i
    b = join(a, "# ") '<<<< Can't Assign to Array
    Next
    MsgBox b
    End Sub
    please help I can not merge

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Can't Assign to Array please help :((

    VB's Join method combines an array to a single string variable. VB's Split takes a single string variables and creates an array. Review your help files.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    21

    Re: Can't Assign to Array please help :((

    Quote Originally Posted by LaVolpe View Post
    VB's Join method combines an array to a single string variable. VB's Split takes a single string variables and creates an array. Review your help files.
    "join function" What alternatives can

  4. #4
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: Can't Assign to Array please help :((

    dim b(1 to 15) as string

    in your for loop:

    b(i) = a(i) & "# "

  5. #5
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Can't Assign to Array please help :((

    Are you trying to do this?
    vb Code:
    1. Private Sub Command1_Click()
    2.     Dim a(1 To 15) As String, i As Long
    3.     Dim b As String
    4.     For i = 1 To 15
    5.         a(i) = "test" & i
    6.     Next
    7.     b = join(a, "#")
    8.     MsgBox b
    9. End Sub
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    21

    Re: Can't Assign to Array please help :((

    Quote Originally Posted by Pradeep1210 View Post
    Are you trying to do this?
    vb Code:
    1. Private Sub Command1_Click()
    2.     Dim a(1 To 15) As String, i As Long
    3.     Dim b As String
    4.     For i = 1 To 15
    5.         a(i) = "test" & i
    6.     Next
    7.     b = join(a, "#")
    8.     MsgBox b
    9. End Sub

    thank you for share Pradeep

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Can't Assign to Array please help :((

    Now that we've helped you, you can help us by marking the thread as resolved. If you have JavaScript enabled you can do that easily by pulling down the Thread Tools menu and selecting the Mark Thread Resolved item. Also if someone has been particularly helpful you have the ability to affect their forum "reputation" by rating their post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width