473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Array and Delimiters

I am having trouble writing code to turn an array into a delimited string.

Dim splitout As String
splitout = Join(DataArray(rows, columns), " ")

rows and columns are integers representing rows and columns quanitity of
datasets.

Could someone help show what I am doing wrong?
When ever I write splitout to to a text file nothing is there.
Nov 20 '05 #1
33 1815
"Peace" <Its the end of the world as we know it@here.com> schrieb
I am having trouble writing code to turn an array into a delimited
string.

Dim splitout As String
splitout = Join(DataArray(rows, columns), " ")

rows and columns are integers representing rows and columns quanitity
of datasets.

Could someone help show what I am doing wrong?
When ever I write splitout to to a text file nothing is there.


How is DataArray declared? It would have to be a 2-dimensional array of
1-dimensional string arrays.

If DataArray is a string array, you can write
splitout = Join(DataArray, " ")

You can also use the shared method System.String.Join.

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
I am sorry for not being complete originally.

rows = dsreportscopy.Tables(0).Rows.Count
columns = dsreportscopy.Tables(0).Columns.Count

Dim DataArray(rows, columns) As Object
For c = 0 To columns - 1
DataArray(r, c) =
dsreportscopy.Tables(0).Columns.Item(c).ColumnName )
For r = 0 To rows - 1
DataArray(r, c) = dsreportscopy.Tables(0).Rows(r).Item(c))
Next
Next

Dim splitout As String
splitout = Join(DataArray(rows, columns), " ")
"Armin Zingler" <az*******@freenet.de> wrote in message
news:eX**************@TK2MSFTNGP11.phx.gbl...
"Peace" <Its the end of the world as we know it@here.com> schrieb
I am having trouble writing code to turn an array into a delimited
string.

Dim splitout As String
splitout = Join(DataArray(rows, columns), " ")

rows and columns are integers representing rows and columns quanitity
of datasets.

Could someone help show what I am doing wrong?
When ever I write splitout to to a text file nothing is there.


How is DataArray declared? It would have to be a 2-dimensional array of
1-dimensional string arrays.

If DataArray is a string array, you can write
splitout = Join(DataArray, " ")

You can also use the shared method System.String.Join.

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
"Peace" <Its the end of the world as we know it@here.com> schrieb
I am sorry for not being complete originally.

rows = dsreportscopy.Tables(0).Rows.Count
columns = dsreportscopy.Tables(0).Columns.Count

Dim DataArray(rows, columns) As Object
For c = 0 To columns - 1
DataArray(r, c) =
dsreportscopy.Tables(0).Columns.Item(c).ColumnName )
For r = 0 To rows - 1
DataArray(r, c) =
dsreportscopy.Tables(0).Rows(r).Item(c))
Next
Next

Dim splitout As String
splitout = Join(DataArray(rows, columns), " ")


Why the first
DataArray(r, c) =
statement? It is outside the loop that uses 'r'.
How do you want to concatenate the dataTable content? One space between each
column and a new line for each record? How do you want to convert the values
to a string?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #4
Hi Armin,

One space (actually would prefer a tab but it was nto accepting Chr(9))
between each column and a new line for each record.

How would you have written this?

The end goal is:
(provided by cindy concerning writing an array to a MS Word table)
- Turn the array into a delimited string (using the VB Join function, for
example). The delimiter can be anything you like, just as long as it's a
character in the text. Or, you'd have to put the individual entries into
"quotes" so that it's clear where the character is NOT a delimiter.

- Assign this string to a RANGE in the Word document (rng.Text = s)

- convert the range (containing the delimited string) to a table (the
ConvertToTable method), assigning it to an object variable (Dim tbl as
Word.Table tbl = rng.ConvertToTable('set the params)

"Armin Zingler" <az*******@freenet.de> wrote in message
news:uV**************@TK2MSFTNGP12.phx.gbl...
"Peace" <Its the end of the world as we know it@here.com> schrieb
I am sorry for not being complete originally.

rows = dsreportscopy.Tables(0).Rows.Count
columns = dsreportscopy.Tables(0).Columns.Count

Dim DataArray(rows, columns) As Object
For c = 0 To columns - 1
DataArray(r, c) =
dsreportscopy.Tables(0).Columns.Item(c).ColumnName )
For r = 0 To rows - 1
DataArray(r, c) =
dsreportscopy.Tables(0).Rows(r).Item(c))
Next
Next

Dim splitout As String
splitout = Join(DataArray(rows, columns), " ")
Why the first
DataArray(r, c) =
statement? It is outside the loop that uses 'r'.
How do you want to concatenate the dataTable content? One space between

each column and a new line for each record? How do you want to convert the values to a string?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
Cor
Hi Peace,

Can you see if this fits your problem?

It makes from a datatable (the part after ds. with a dataset) a arraylist
with comma seperated strings.

Test it very good, because in this way I did not make it before and I become
always confused to check xy, yx

I hope it works for you?

Cor
\\\
Dim a As New ArrayList
For i As Integer = 0 To dt.Columns.Count - 1
Dim b As New System.Text.StringBuilder
For y As Integer = 0 To dt.Rows.Count - 1
b.Append(dt.Rows(y)(i))
If y <> dt.Rows.Count - 1 Then
b.Append(",")
End If
Next
a.Add(b.ToString)
Next
///
Nov 20 '05 #6
Hi Cor / Peace,

It looks the basic approach here would work. You're building a comma-delimited
string, yes? However, you should loop columns for each row. Think of the data
as each record's fields are a column in a row:

Field1,Field2,Field3
Data1,Data2,Data3
Data1,Data2,Data3

If you're going this route, no need to put it into an array - you'll already
have the delimited string! Just keep on concatenating the string: After
processing each row, add a vbCR character to the string. (vbCR because this is
what Word understands as "new paragraph", and works with best when converting
delimited strings to tables).

Basically, if you'd copy paste my sample, above, into Word it would convert
with no problems into a table. This is the kind of end-result you need to
generate.
Can you see if this fits your problem?

It makes from a datatable (the part after ds. with a dataset) a arraylist
with comma seperated strings.

Test it very good, because in this way I did not make it before and I become
always confused to check xy, yx
\\\
Dim a As New ArrayList
For i As Integer = 0 To dt.Columns.Count - 1
Dim b As New System.Text.StringBuilder
For y As Integer = 0 To dt.Rows.Count - 1
b.Append(dt.Rows(y)(i))
If y <> dt.Rows.Count - 1 Then
b.Append(",")
End If
Next
a.Add(b.ToString)
Next
///


-- Cindy

Nov 20 '05 #7
Cor
Hi Cindy,

I was not sure from the message of Peace if it had to be a csv file was what
you had said.

The arraylist and stringbuilder approach I use because that is very fast.
(Of course I could do it in one time)

(to make it even more efficient now I know it has to be a CSV File)
b.Append(dt.Rows(y)(i))
If y <> dt.Rows.Count - 1 Then
b.Append(",")
End If if y<>dt.Rows.count - 1 then
b.append(",")
else
b.append(vbcrlf)
end if

And after that it is just making from the strings in the arraylist a csv
file by

For ......... (but I did (and do not want to do everything), that is not
good for Peace) :-))

Although it is almost nothing to do it.

But if I understand it wrong about that csv textfile, please message me.

Cor

Hi Cor / Peace,

It looks the basic approach here would work. You're building a comma-delimited string, yes? However, you should loop columns for each row. Think of the data as each record's fields are a column in a row:

Field1,Field2,Field3
Data1,Data2,Data3
Data1,Data2,Data3

If you're going this route, no need to put it into an array - you'll already have the delimited string! Just keep on concatenating the string: After
processing each row, add a vbCR character to the string. (vbCR because this is what Word understands as "new paragraph", and works with best when converting delimited strings to tables).

Basically, if you'd copy paste my sample, above, into Word it would convert with no problems into a table. This is the kind of end-result you need to
generate.
Can you see if this fits your problem?

It makes from a datatable (the part after ds. with a dataset) a

arraylist with comma seperated strings.

Test it very good, because in this way I did not make it before and I become always confused to check xy, yx

\\\
Dim a As New ArrayList
For i As Integer = 0 To dt.Columns.Count - 1
Dim b As New System.Text.StringBuilder
For y As Integer = 0 To dt.Rows.Count - 1
b.Append(dt.Rows(y)(i))
If y <> dt.Rows.Count - 1 Then
b.Append(",")
End If
Next
a.Add(b.ToString)
Next
///


-- Cindy

Nov 20 '05 #8
Cindy,

Are you saying if I copy and paste the array into word it will make a table
out of it?

I am sorry if I am not understanding.

"Cindy M -WordMVP-" <C.*********@hispeed.ch> wrote in message
news:VA.000090a5.0081e2ea@speedy...
Hi Cor / Peace,

It looks the basic approach here would work. You're building a comma-delimited string, yes? However, you should loop columns for each row. Think of the data as each record's fields are a column in a row:

Field1,Field2,Field3
Data1,Data2,Data3
Data1,Data2,Data3

If you're going this route, no need to put it into an array - you'll already have the delimited string! Just keep on concatenating the string: After
processing each row, add a vbCR character to the string. (vbCR because this is what Word understands as "new paragraph", and works with best when converting delimited strings to tables).

Basically, if you'd copy paste my sample, above, into Word it would convert with no problems into a table. This is the kind of end-result you need to
generate.
Can you see if this fits your problem?

It makes from a datatable (the part after ds. with a dataset) a arraylist with comma seperated strings.

Test it very good, because in this way I did not make it before and I become always confused to check xy, yx

\\\
Dim a As New ArrayList
For i As Integer = 0 To dt.Columns.Count - 1
Dim b As New System.Text.StringBuilder
For y As Integer = 0 To dt.Rows.Count - 1
b.Append(dt.Rows(y)(i))
If y <> dt.Rows.Count - 1 Then
b.Append(",")
End If
Next
a.Add(b.ToString)
Next
///


-- Cindy

Nov 20 '05 #9
> For ......... (but I did (and do not want to do everything), that is not
good for Peace) :-))


I appreciate your concern about my wellbeing but it is not like I have not
tried and I have spent a good deal amount of time writing the excel sample
that was connected to this. I am putting in the legwork so please help if
you can. I also am in a production environment which I know you know what
that means and I have spent too much time on this already.

Nov 20 '05 #10
Cor
Hi Peace,

It is very easy to do and I will when I and you have both an answer from
Cindy,
I think it is extra about 4 lines of code.

Cor
I appreciate your concern about my wellbeing but it is not like I have not
tried and I have spent a good deal amount of time writing the excel sample
that was connected to this. I am putting in the legwork so please help if
you can. I also am in a production environment which I know you know what
that means and I have spent too much time on this already.

Nov 20 '05 #11
Thanks man.....

beginning to sweat this one.

"Cor" <no*@non.com> wrote in message
news:uP**************@TK2MSFTNGP11.phx.gbl...
Hi Peace,

It is very easy to do and I will when I and you have both an answer from
Cindy,
I think it is extra about 4 lines of code.

Cor
I appreciate your concern about my wellbeing but it is not like I have not tried and I have spent a good deal amount of time writing the excel sample that was connected to this. I am putting in the legwork so please help if you can. I also am in a production environment which I know you know what that means and I have spent too much time on this already.


Nov 20 '05 #12
Hi Cor,
But if I understand it wrong about that csv textfile

csv FORMAT, but not an actual file.

Peace needs to put his data in a delimited string format,
carried in a string variable (strMyData, let's call it).
The field delimiter doesn't have to be a comma, it could
also be a TAB character (Chr(9)) (which he has indicated
he'd prefer, as I recall), or anything else. Record
delimiter *must* be a Chr(13).

Once he has that, it has to go into a Word range, then it
can be converted to a Word table, roughly like this:

Dim rng as Word.Range = ActiveDocument.Range
rng.Collapse wdCollapseEnd
rng.Text = strMyData
Dim tbl as Word Table = rng.convertToTable('params here)

Thanks for providing the datatable to string manipulation
stuff in "NET-speak" :-)

-- Cindy

Nov 20 '05 #13
Hi Cindy,
this is peace I thought it was safe to go back to my old name.....
SO then, to create the delimited string with my array called datasetarray
how would I do this?

"Cindy M -WordMVP-" <C.*********@hispeed.ch> wrote in message
news:VA.000090b7.008df781@speedy...
Hi Cor,
But if I understand it wrong about that csv textfile

csv FORMAT, but not an actual file.

Peace needs to put his data in a delimited string format,
carried in a string variable (strMyData, let's call it).
The field delimiter doesn't have to be a comma, it could
also be a TAB character (Chr(9)) (which he has indicated
he'd prefer, as I recall), or anything else. Record
delimiter *must* be a Chr(13).

Once he has that, it has to go into a Word range, then it
can be converted to a Word table, roughly like this:

Dim rng as Word.Range = ActiveDocument.Range
rng.Collapse wdCollapseEnd
rng.Text = strMyData
Dim tbl as Word Table = rng.convertToTable('params here)

Thanks for providing the datatable to string manipulation
stuff in "NET-speak" :-)

-- Cindy

Nov 20 '05 #14
Hi Scorpion53061,
SO then, to create the delimited string with my array called datasetarray
how would I do this?

Cor was actually taking care of this part? I'm not that conversant in
NET-speak, yet, to be able to give you "good" code for the non-Word part.

Note that in the original discussion on your question about how to make a
table in Word I gave you an EXAMPLE what you could do. I didn't say you HAD
to have an array. It all depends on where you're starting from...

From the additional information you've provided since, in this thread, it
looks like you should go directly from your data to the delimited string;
an array would be an extra (and unnecessary) step.

What you NEED is the delimited string. How you get there depends entirely
on the specific circumstances. Use what's most efficient or convenient.

-- Cindy

Nov 20 '05 #15
sure. The whole exercise was because writing a dataset cell by cell in a
Word table was taking too long.

So hopefully if I can get this array to a delimited string I will be okay
from there. I will wait for Cor.

Thank you much for your help!!

"Cindy M -WordMVP-" <C.*********@hispeed.ch> wrote in message
news:VA.000090ca.0100e8fb@speedy...
Hi Scorpion53061,
SO then, to create the delimited string with my array called datasetarray how would I do this?
Cor was actually taking care of this part? I'm not that conversant in
NET-speak, yet, to be able to give you "good" code for the non-Word part.

Note that in the original discussion on your question about how to make a
table in Word I gave you an EXAMPLE what you could do. I didn't say you

HAD to have an array. It all depends on where you're starting from...

From the additional information you've provided since, in this thread, it
looks like you should go directly from your data to the delimited string;
an array would be an extra (and unnecessary) step.

What you NEED is the delimited string. How you get there depends entirely
on the specific circumstances. Use what's most efficient or convenient.

-- Cindy

Nov 20 '05 #16
Cor
Hi Peace,

Complete with test .
The first part is only to build up a table.

I hope it is also as Cindy told it, so lets wait her comments?

Cor

\\\
Option Strict On
Public Module Main
Public Sub Main()
'First the testtable
'Make a datatable with 8 columns
Dim dt As New DataTable
For i As Integer = 0 To 7
Dim dc As New DataColumn(Chr(i + 48))
dt.Columns.Add(dc)
Next
'And 12 rows every column filled with a letter
For i As Integer = 0 To 11
dt.Rows.Add(dt.NewRow)
For y As Integer = 0 To dt.Columns.Count - 1
dt.Rows(i)(y) = Chr(y + 65)
Next
Next
'Conform the wish of Cindy Conventional build string
'brrr but only to show the start of the testtable
Dim Scorpion As String
For i As Integer = 0 To dt.Rows.Count - 1
For y As Integer = 0 To dt.Columns.Count - 1
Scorpion = Scorpion & dt.Rows(i)(y).tostring
If y <> dt.Columns.Count - 1 Then
Scorpion = Scorpion & chr(9)
Else
Scorpion = Scorpion & chr(13)
End If
Next
Next

MessageBox.Show(Scorpion)
'Here start conversion XY to YX
Dim a As New ArrayList
For i As Integer = 0 To dt.Columns.Count - 1
Dim b As New System.Text.StringBuilder
For y As Integer = 0 To dt.Rows.Count - 1
b.Append(dt.Rows(y)(i))
If y <> dt.Rows.Count - 1 Then
b.Append(Chr(9))
Else
b.Append(Chr(13))
End If
Next
a.Add(b.ToString)
Next
Dim Peace As New System.Text.StringBuilder
For i As Integer = 0 To a.Count - 1
Peace.Append(a(i).ToString)
Next
Dim Cindy As String = Peace.ToString

MessageBox.Show(Cindy)
'Text from Cindy
' Dim rng As Word.Range = ActiveDocument.Range
' rng.Collapse(wdCollapseEnd)
' rng.Text = Cindy
' Dim tbl as Word Table = rng.convertToTable('params here)
End Sub
End Module
///
I hope this helps a little bit?

Cor
Nov 20 '05 #17
Cor,

Frustration.........
"Cor" <no*@non.com> wrote in message
news:eM**************@TK2MSFTNGP10.phx.gbl...
Hi Peace,

Complete with test .
The first part is only to build up a table.

I hope it is also as Cindy told it, so lets wait her comments?

Cor

\\\
Option Strict On
Public Module Main
Public Sub Main()
'First the testtable
'Make a datatable with 8 columns
Dim dt As New DataTable
For i As Integer = 0 To 7
Dim dc As New DataColumn(Chr(i + 48))
dt.Columns.Add(dc)
Next
'And 12 rows every column filled with a letter
For i As Integer = 0 To 11
dt.Rows.Add(dt.NewRow)
For y As Integer = 0 To dt.Columns.Count - 1
dt.Rows(i)(y) = Chr(y + 65)
Next
Next
'Conform the wish of Cindy Conventional build string
'brrr but only to show the start of the testtable
Dim Scorpion As String
For i As Integer = 0 To dt.Rows.Count - 1
For y As Integer = 0 To dt.Columns.Count - 1
Scorpion = Scorpion & dt.Rows(i)(y).tostring
If y <> dt.Columns.Count - 1 Then
Scorpion = Scorpion & chr(9)
Else
Scorpion = Scorpion & chr(13)
End If
Next
Next

MessageBox.Show(Scorpion)
'Here start conversion XY to YX
Dim a As New ArrayList
For i As Integer = 0 To dt.Columns.Count - 1
Dim b As New System.Text.StringBuilder
For y As Integer = 0 To dt.Rows.Count - 1
b.Append(dt.Rows(y)(i))
If y <> dt.Rows.Count - 1 Then
b.Append(Chr(9))
Else
b.Append(Chr(13))
End If
Next
a.Add(b.ToString)
Next
Dim Peace As New System.Text.StringBuilder
For i As Integer = 0 To a.Count - 1
Peace.Append(a(i).ToString)
Next
Dim Cindy As String = Peace.ToString

MessageBox.Show(Cindy)
'Text from Cindy
' Dim rng As Word.Range = ActiveDocument.Range
' rng.Collapse(wdCollapseEnd)
' rng.Text = Cindy
' Dim tbl as Word Table = rng.convertToTable('params here)
End Sub
End Module
///
I hope this helps a little bit?

Cor

Nov 20 '05 #18
Cor
??

Frustration.........

Not at all, what do you mean?

Cor
Nov 20 '05 #19
I am frustrated due to lack of the ability to communicate what I am trying
to do. But that is my bad for not explaining it well.

A dataarray with 2 elements (dataarray(r,c)) where r = the rows of a dataset
and c is the columns of a dataset.

We want to write that dataarray to a delimited string.

It is back to the drawing board on this
"Cor" <no*@non.com> wrote in message
news:eG**************@TK2MSFTNGP10.phx.gbl...
??

Frustration.........

Not at all, what do you mean?

Cor

Nov 20 '05 #20
Cor
Hi Scorpion,

That is the first part of the sample, just run and try it.
(Although if you wish is I will rewrite the first part also using the
stringbuilder (two rows of code), that is a little bit nicer if it is real a
hugh dataset)

I used a datatable,
but if you read
ds.tables(0) you have a datatable.

The second part of the sample changes xy to yx

Cor
I am frustrated due to lack of the ability to communicate what I am trying
to do. But that is my bad for not explaining it well.

A dataarray with 2 elements (dataarray(r,c)) where r = the rows of a dataset and c is the columns of a dataset.

We want to write that dataarray to a delimited string.

Nov 20 '05 #21
The datasets can be extremely huge depending if the enduser requests a lot
of data. :(

"Cor" <no*@non.com> wrote in message
news:u2**************@TK2MSFTNGP12.phx.gbl...
Hi Scorpion,

That is the first part of the sample, just run and try it.
(Although if you wish is I will rewrite the first part also using the
stringbuilder (two rows of code), that is a little bit nicer if it is real a hugh dataset)

I used a datatable,
but if you read
ds.tables(0) you have a datatable.

The second part of the sample changes xy to yx

Cor
I am frustrated due to lack of the ability to communicate what I am trying to do. But that is my bad for not explaining it well.

A dataarray with 2 elements (dataarray(r,c)) where r = the rows of a

dataset
and c is the columns of a dataset.

We want to write that dataarray to a delimited string.


Nov 20 '05 #22
Cor
Hi Scorpion,

As you wishes
This is not XY, YX conversion

This is a string of lines delimited with chr(13) you see what you want there
and a Tab
You can of course also make vbcrlf and ","

I hope this helps?

Cor

\\\
'As Scorpion wishes a dataset
'Make a datatable with 8 columns
Dim ds As New DataSet
Dim dt As New DataTable("scorpion")
For i As Integer = 0 To 7
Dim dc As New DataColumn(Chr(i + 48))
dt.Columns.Add(dc)
Next
'And 12 rows every column filled with a letter
For i As Integer = 0 To 11
dt.Rows.Add(dt.NewRow)
For y As Integer = 0 To dt.Columns.Count - 1
dt.Rows(i)(y) = Chr(y + 65)
Next
Next
ds.Tables.Add(dt)
'End build testdataset
'Make string Conform the wish of Scorpion build with stringbuilder
Dim Scorpion As New System.Text.StringBuilder
For i As Integer = 0 To ds.Tables("scorpion").Rows.Count - 1
For y As Integer = 0 To ds.Tables("scorpion").Columns.Count - 1
Scorpion.Append(ds.Tables("scorpion").Rows(i)(y).t ostring)
If y <> ds.Tables("scorpion").Columns.Count - 1 Then
Scorpion.Append(Chr(9))
Else
Scorpion.Append(Chr(13))
End If
Next
Next

MessageBox.Show(Scorpion.ToString)
///
Nov 20 '05 #23
This may work.I wil let you know.

Respond to IronMan please and SHOUT to people not to respond. Shut it down
before it starts....

He is in the thread "(Search Tool) Alright Already I Fixed It". I would do
it myself but he seems to get off on me responding to him.

I knew it was a mistake going back to my old name.. <sigh>
"Cor" <no*@non.com> wrote in message
news:OF**************@tk2msftngp13.phx.gbl...
Hi Scorpion,

As you wishes
This is not XY, YX conversion

This is a string of lines delimited with chr(13) you see what you want there and a Tab
You can of course also make vbcrlf and ","

I hope this helps?

Cor

\\\
'As Scorpion wishes a dataset
'Make a datatable with 8 columns
Dim ds As New DataSet
Dim dt As New DataTable("scorpion")
For i As Integer = 0 To 7
Dim dc As New DataColumn(Chr(i + 48))
dt.Columns.Add(dc)
Next
'And 12 rows every column filled with a letter
For i As Integer = 0 To 11
dt.Rows.Add(dt.NewRow)
For y As Integer = 0 To dt.Columns.Count - 1
dt.Rows(i)(y) = Chr(y + 65)
Next
Next
ds.Tables.Add(dt)
'End build testdataset
'Make string Conform the wish of Scorpion build with stringbuilder
Dim Scorpion As New System.Text.StringBuilder
For i As Integer = 0 To ds.Tables("scorpion").Rows.Count - 1
For y As Integer = 0 To ds.Tables("scorpion").Columns.Count - 1 Scorpion.Append(ds.Tables("scorpion").Rows(i)(y).t ostring)
If y <> ds.Tables("scorpion").Columns.Count - 1 Then
Scorpion.Append(Chr(9))
Else
Scorpion.Append(Chr(13))
End If
Next
Next

MessageBox.Show(Scorpion.ToString)
///

Nov 20 '05 #24
Cor
Hi Cindy,

I did make that sample,
Will you look at it if this is what you did mean?

I did place it in the other sub thread , with a lot of answer from Scorpion,
so I gues you missed it.

Cor

\\\
Option Strict On
Public Module Main
Public Sub Main()
'First the testtable
'Make a datatable with 8 columns
Dim dt As New DataTable
For i As Integer = 0 To 7
Dim dc As New DataColumn(Chr(i + 48))
dt.Columns.Add(dc)
Next
'And 12 rows every column filled with a letter
For i As Integer = 0 To 11
dt.Rows.Add(dt.NewRow)
For y As Integer = 0 To dt.Columns.Count - 1
dt.Rows(i)(y) = Chr(y + 65)
Next
Next
'Conform the wish of Cindy Conventional build string
'brrr but only to show the start of the testtable
Dim Scorpion As String
For i As Integer = 0 To dt.Rows.Count - 1
For y As Integer = 0 To dt.Columns.Count - 1
Scorpion = Scorpion & dt.Rows(i)(y).tostring
If y <> dt.Columns.Count - 1 Then
Scorpion = Scorpion & chr(9)
Else
Scorpion = Scorpion & chr(13)
End If
Next
Next

MessageBox.Show(Scorpion)
'Here start conversion XY to YX
Dim a As New ArrayList
For i As Integer = 0 To dt.Columns.Count - 1
Dim b As New System.Text.StringBuilder
For y As Integer = 0 To dt.Rows.Count - 1
b.Append(dt.Rows(y)(i))
If y <> dt.Rows.Count - 1 Then
b.Append(Chr(9))
Else
b.Append(Chr(13))
End If
Next
a.Add(b.ToString)
Next
Dim Peace As New System.Text.StringBuilder
For i As Integer = 0 To a.Count - 1
Peace.Append(a(i).ToString)
Next
Dim Cindy As String = Peace.ToString

MessageBox.Show(Cindy)
'Text from Cindy
' Dim rng As Word.Range = ActiveDocument.Range
' rng.Collapse(wdCollapseEnd)
' rng.Text = Cindy
' Dim tbl as Word Table = rng.convertToTable('params here)
End Sub
End Module
Cor
Nov 20 '05 #25
I didn't see Cindy's response to you.

Would you post it in with your next message?

My newsserver may have dropped it for some reason.

"Cor" <no*@non.com> wrote in message
news:es**************@TK2MSFTNGP11.phx.gbl...
Hi Cindy,

I did make that sample,
Will you look at it if this is what you did mean?

I did place it in the other sub thread , with a lot of answer from Scorpion, so I gues you missed it.

Cor

\\\
Option Strict On
Public Module Main
Public Sub Main()
'First the testtable
'Make a datatable with 8 columns
Dim dt As New DataTable
For i As Integer = 0 To 7
Dim dc As New DataColumn(Chr(i + 48))
dt.Columns.Add(dc)
Next
'And 12 rows every column filled with a letter
For i As Integer = 0 To 11
dt.Rows.Add(dt.NewRow)
For y As Integer = 0 To dt.Columns.Count - 1
dt.Rows(i)(y) = Chr(y + 65)
Next
Next
'Conform the wish of Cindy Conventional build string
'brrr but only to show the start of the testtable
Dim Scorpion As String
For i As Integer = 0 To dt.Rows.Count - 1
For y As Integer = 0 To dt.Columns.Count - 1
Scorpion = Scorpion & dt.Rows(i)(y).tostring
If y <> dt.Columns.Count - 1 Then
Scorpion = Scorpion & chr(9)
Else
Scorpion = Scorpion & chr(13)
End If
Next
Next

MessageBox.Show(Scorpion)
'Here start conversion XY to YX
Dim a As New ArrayList
For i As Integer = 0 To dt.Columns.Count - 1
Dim b As New System.Text.StringBuilder
For y As Integer = 0 To dt.Rows.Count - 1
b.Append(dt.Rows(y)(i))
If y <> dt.Rows.Count - 1 Then
b.Append(Chr(9))
Else
b.Append(Chr(13))
End If
Next
a.Add(b.ToString)
Next
Dim Peace As New System.Text.StringBuilder
For i As Integer = 0 To a.Count - 1
Peace.Append(a(i).ToString)
Next
Dim Cindy As String = Peace.ToString

MessageBox.Show(Cindy)
'Text from Cindy
' Dim rng As Word.Range = ActiveDocument.Range
' rng.Collapse(wdCollapseEnd)
' rng.Text = Cindy
' Dim tbl as Word Table = rng.convertToTable('params here)
End Sub
End Module
Cor

Nov 20 '05 #26
Cor
See did not response,

But my previous message was a little bit overloaded with answers from you
and therefore I was afraid that see would not see it.

:-))

Cor

I didn't see Cindy's response to you.
Would you post it in with your next message?
My newsserver may have dropped it for some reason.

Nov 20 '05 #27
On Wed, 31 Dec 2003 12:13:00 -0600, Peace wrote:
I am sorry for not being complete originally.

rows = dsreportscopy.Tables(0).Rows.Count
columns = dsreportscopy.Tables(0).Columns.Count

Dim DataArray(rows, columns) As Object
For c = 0 To columns - 1
DataArray(r, c) =
dsreportscopy.Tables(0).Columns.Item(c).ColumnName )
For r = 0 To rows - 1
DataArray(r, c) = dsreportscopy.Tables(0).Rows(r).Item(c))
Next
Next

Dim splitout As String
splitout = Join(DataArray(rows, columns), " ")
"Armin Zingler" <az*******@freenet.de> wrote in message
news:eX**************@TK2MSFTNGP11.phx.gbl...
"Peace" <Its the end of the world as we know it@here.com> schrieb
I am having trouble writing code to turn an array into a delimited
string.

Dim splitout As String
splitout = Join(DataArray(rows, columns), " ")

rows and columns are integers representing rows and columns quanitity
of datasets.

Could someone help show what I am doing wrong?
When ever I write splitout to to a text file nothing is there.


How is DataArray declared? It would have to be a 2-dimensional array of
1-dimensional string arrays.

If DataArray is a string array, you can write
splitout = Join(DataArray, " ")

You can also use the shared method System.String.Join.

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


Since I'm entering this discussion late, you may have already solved your
problem. But here's my "suggestion"
My understanding is that if the Table has the following rows and columns:

A B C
D E F
G H I

it should give you a string that looks like:

A<tab>B<tab>C<cr><D<tab>E<tab>F<tab><cr>G<tab>H<ta b>I<cr>
The Rows property of the DataTable has an ItemArray method that returns an
array of the items in the row. Perhaps you could do somthing like this:

Dim strDataStr As String

With dsreportscopy.Tables(0)
For x As Integer = 0 to .Rows.Count - 1
strDataStr &= String.Join(Chr(9),CType(.Rows(x).ItemArray,String ())
strDataStr &= Chr(13)
Next
End With

This code is untested and I'm not sure if the ItemArray needs to be casted
to a string array. And if the rows and columns do not all contain string
data, I'm not sure how that will affect the outcome. Also, if there are
lots of concatenations, you may wish to use a StringBuilder.

If I am completely off base, please ignore this post.

HTH a little.

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #28
Any help you would give would please me greatly.

I have a array of my dataset and I wrote it to Excel without a problem. MS
Word is my issue. And I was suppose to have had it done many moons ago.

I cannot seem to find a way to get an array of a dataset (ArrayData (r,c)
r - rows, c = columns) into a MS Word table.

If anyone can help I would be most greatful.
"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:18******************************@40tude.net.. .
On Wed, 31 Dec 2003 12:13:00 -0600, Peace wrote:
I am sorry for not being complete originally.

rows = dsreportscopy.Tables(0).Rows.Count
columns = dsreportscopy.Tables(0).Columns.Count

Dim DataArray(rows, columns) As Object
For c = 0 To columns - 1
DataArray(r, c) =
dsreportscopy.Tables(0).Columns.Item(c).ColumnName )
For r = 0 To rows - 1
DataArray(r, c) = dsreportscopy.Tables(0).Rows(r).Item(c)) Next
Next

Dim splitout As String
splitout = Join(DataArray(rows, columns), " ")
"Armin Zingler" <az*******@freenet.de> wrote in message
news:eX**************@TK2MSFTNGP11.phx.gbl...
"Peace" <Its the end of the world as we know it@here.com> schrieb
I am having trouble writing code to turn an array into a delimited
string.

Dim splitout As String
splitout = Join(DataArray(rows, columns), " ")

rows and columns are integers representing rows and columns quanitity
of datasets.

Could someone help show what I am doing wrong?
When ever I write splitout to to a text file nothing is there.

How is DataArray declared? It would have to be a 2-dimensional array of
1-dimensional string arrays.

If DataArray is a string array, you can write
splitout = Join(DataArray, " ")

You can also use the shared method System.String.Join.

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


Since I'm entering this discussion late, you may have already solved your
problem. But here's my "suggestion"
My understanding is that if the Table has the following rows and columns:

A B C
D E F
G H I

it should give you a string that looks like:

A<tab>B<tab>C<cr><D<tab>E<tab>F<tab><cr>G<tab>H<ta b>I<cr>
The Rows property of the DataTable has an ItemArray method that returns an
array of the items in the row. Perhaps you could do somthing like this:

Dim strDataStr As String

With dsreportscopy.Tables(0)
For x As Integer = 0 to .Rows.Count - 1
strDataStr &= String.Join(Chr(9),CType(.Rows(x).ItemArray,String ())
strDataStr &= Chr(13)
Next
End With

This code is untested and I'm not sure if the ItemArray needs to be casted
to a string array. And if the rows and columns do not all contain string
data, I'm not sure how that will affect the outcome. Also, if there are
lots of concatenations, you may wish to use a StringBuilder.

If I am completely off base, please ignore this post.

HTH a little.

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Nov 20 '05 #29
Hi Cor,
I did make that sample,
Will you look at it if this is what you did mean?

I think the real judge of this will have to be scorp :-)
Does he get a comma-delimited string he can dump into Word?

I'm a bit over-loaded at the moment; brain's smokin' In
order to see whether the sample really works, I first need
some time to read up on datasets, etc! From a quick scan,
just looking at the string building logic, it looks like it
should work.

-- Cindy

Nov 20 '05 #30
Hi Scorpion53061,
I cannot seem to find a way to get an array of a dataset (ArrayData (r,c)
r - rows, c = columns) into a MS Word table.

You can't. Stop hitting your head on the wall, wipe up the blood, put a
band-aid on the bruise, take a deep breath, then read and think about what
we've been telling you.

Word doesn't know how to deal with an array like this. You HAVE to get this
into a delimited string. If you already have a dataset, forget about the
array and process the data set the way Cor or Chris is showing you, by
"walking" the records and building the string.

If all you have is the array, then loop through the array in order to build
the delimted string. In really old-fashioned, VB-speak, ugly code (yeah, I
know it should use UBound, but I'm not sure I remember how that goes for a
two-dimensional array):
For i = 0 to NrRows 'Records
For j = 0 to NrCols 'Fields
strData = strData & Array(i,j) & vbTAB
Next j
strData = strDAta & vbCR
Next i

-- Cindy

Nov 20 '05 #31
> You can't. Stop hitting your head on the wall, wipe up the blood, put a
band-aid on the bruise, take a deep breath, then read and think about what
we've been telling you.


LOL

I will start over and try everything again....
Nov 20 '05 #32
On Thu, 8 Jan 2004 11:40:39 -0600, scorpion53061 wrote:
Any help you would give would please me greatly.


I'm not familiar with Word automation. I was only pointing out a possible
method for taking your Dataset and turning it into a delimited string. How
to get that string into Word is beyond my feeble skills.

Sorry

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #33
Cor
Hi Cindy,

Thanks for the response even if you are busy.

Cor
Nov 20 '05 #34

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: brianshields | last post by:
array("a", "b", "c", "d", "e"); I want to now be able to load "b" into a variable ($var) then print it out print $var thanks!
6
by: Sean Bartholomew | last post by:
i have a bit of a problem. im parsing a record string using strtok but im encountering back to back whitespaces (\t\t) due to empty fields from my database export. the STRTOK function reads up to...
9
by: Steve | last post by:
Hello (and a happy new year) I'm quite new to C++ and have to programm something for school and can't get my head around a couple of things, but at the moment this one is the most important for...
11
by: Walter Dnes (delete the 'z' to get my real address | last post by:
I've noticed a few threads (full of sound and fury, signifying nothing) here recently about allocation of large memory blocks. I'm about to start on a personal pet project where I'll be using...
11
by: miketigerwoods | last post by:
I'm having problems where I need to parse a command line, and place each token from strtok() into an array. I've read here: http://www.phim.unibe.ch/comp_doc/c_manual/C/CONCEPT/arrays.html (at...
2
by: Anil | last post by:
Hi All, I have a string which has product names, which are seperated by comma. The number of products in the string are random. I want to populate the array using the string, one product per...
4
by: Prabhu | last post by:
Hi, We are having problem in converting a byte array to string, The byte array has char(174), char(175), char(240), char(242) and char(247) as delimiters for the message. when we use...
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
1
by: Gustav | last post by:
Hi! I use a regex (?<!\\?)('|\\+|:) to split a string to a String. The String i get after splitting is correctly splitted but contains all the delimiters i use to decide where the string...
3
by: rupinderbatra | last post by:
Hello everyone, I am using a regular expression to parse a text string into various parts -- for ex: string "How do you do" will be changed to array with all the words and white spaces. I am...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.