Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET General (http://www.xtremevbtalk.com/-net-general/)
-   -   Get data in to an array without defined elements. How? (http://www.xtremevbtalk.com/-net-general/328742-data-array-defined-elements.html)

skyfox 09-01-2017 10:35 AM

Get data in to an array without defined elements. How?
Hopefully the title wasn't too confusing as my terminology may be off. The following statement, takes contents of a textbox with comma seperated values and puts them in to a string array called my values.

textbox1. text contains.... "1,2,3,4,5,6" etc. (all numeric values)


Dim MyValues As String() = textBox1.Text.Split(New Char() {","c})
What I want to do is, instead of comma seperated values from a text box, I want to get content of a string array (all elements) in to MYValues() from above.

So I have;

Dim MyStrings(25) as string
What is the proper syntax to get the values in "MyStrings(25)" put in to "MyValues()"?

I could loop thru "MyStrings" array and create a resulting string with comma separated values and then use the split function to load the data in to "Myvalues" like the example above. But that seems like several unnecessary steps. Just in case if anyone is wondering "Myvalues" is sent to a device via serial communications. So I am guessing it is a type of character array of some sort.


Goggy 09-02-2017 01:22 AM

I hope I understood you rite, but if so. You could take a look at the join function.

It works like so:


    Dim MyStrings(25) As String

        For i As Integer = 65 To 90
            MyStrings(i - 65) = Chr(i)

        MsgBox(Join(MyStrings, ",")) ' <-----Joins the array

skyfox 09-02-2017 01:44 AM

Thanks Goggy,

Thanks for the reply. Not exactly what I was looking for. (Perhaps I may be confused on this)

Lets say.......

textbox has " 1, 2, 3"

MyArray of strings has...

MyArray(0) =1
MyArray(1) =2
MyArray(2)= 3

Dim MyValues As String() = textBox1.Text.Split(New Char() {","c})

This removes the comma and puts 1 and 2 and 3 in to MyValues array. Will the join function do the same? I want to get 1 and 2 and 3 from the array and put it in to MyValues string array exactly like the split function does with the textbox contents.

It is late and my head is spinning from this seemingly trivial task. (that and a half a bottle of Kentucky Bourbon. Nectar of the God's if you will)

On a side note, people that gave the world "Stroopwafel", can't possibly be all that useless.

Goggy 09-02-2017 01:47 AM

Yes it will do the reverse. For the delimiter you could use any string value or a empty string if you like... :)

on a side note... how do you know about our stroopwafels? :P

skyfox 09-02-2017 02:17 AM

Thanks Goggy,

I will give it a go in the morning. About the stroopwafels.... Long story short, My girlfriend was adopted by Dutch Parents. Her dad comes from the family of famed dutch painter (at least according to her), Mezdag. In fact, I believe the 100th Anniversary celebration was last year in Belgium if I am not mistaken. We were invited to attend, but was not able to go. There is a huge Mezdag clan here in the Pacific Northwest in the US (Washington & Oregon) and in Alaska. In fact, they might even out number the Mezdag's in Holland now. She speaks fluent Dutch as well. She told me when they were growing up, they had to speak Dutch when they were upstairs and English when they were downstairs. I got to meet her dad before he passed away few years ago. He was an incredible and a kind gentleman. He had five kid of his own and adopted and cared for 5 more kids. He even had homeless people living on his property in tents until they could get back on their feet. So, that was my first experience with the Dutch (actually 2nd because I come from a country where it was a dutch Colony in the 1800's) and I say CHEERS TO ALL OF YOU! Love all those Sambol as well!!!!

Goggy 09-02-2017 02:22 AM


Thats an impressive and wonderful story. :-) Good to hear the land of the stroopwafels is appreciated in other parts of the world as well.

I hope the code works for ya in the morning.

passel 09-07-2017 01:46 PM

p.s. My mistake. I thought this was a VB6 question for some reason.
Assuming my premise below is correct, to copy the one array to a dynamic array you can use the .Clone method in VB.Net.
MyValues = MyStrings.Clone


Originally Posted by skyfox (Post 1411092)
So I have;

Dim MyStrings(25) as string
What is the proper syntax to get the values in "MyStrings(25)" put in to "MyValues()"?

I don't see that he wants to join the elements of the one array into a single string. He has indicated twice that he wants to copy the elements of the MyStrings array into the MyValues array so that the arrays match.

I'm not sure why you wouldn't just do
MyValues = MyStrings

if you want to copy the strings in MyStrings array into the MyValues array, a one to one copy.

All times are GMT -6. The time now is 03:40 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.