Hello,
I have a string that I am trying to add each char to a datatable row.
for example if I have a string that looks like "abcdefg", I would like
to break it up into an array of characters so I can do this:
myDataTable.Rows.Add(array())
instead of myDataTable.Rows.Add("a","b","c","d","e","f","g")
You help is greatly appreciated!
thanks :) 6 2338
You need to convert the string to an array of characters:
Dim chararray As Char() = MyString.ToCharArray()
and then feed the array of characters to the Rows.Add method:
myDataTable.Rows.Add(chararray)
If you do not need to 'save' the interim result for another purpose then you
could feed it in directly:
myDataTable.Rows.Add(MyString.ToCharArray())
character
"Paulers" <Su*******@gmail.comwrote in message
news:11**********************@s34g2000cwa.googlegr oups.com...
Hello,
I have a string that I am trying to add each char to a datatable row.
for example if I have a string that looks like "abcdefg", I would like
to break it up into an array of characters so I can do this:
myDataTable.Rows.Add(array())
instead of myDataTable.Rows.Add("a","b","c","d","e","f","g")
You help is greatly appreciated!
thanks :)
Hello and thanks for your response!
I gave that a try and when I display my DataGridView it shows
System.Char[] in the first col.
Here is what I did
Dim d As DataTable = New DataTable
Dim line As String = "abcdefg"
d.Rows.Add(line.ToCharArray())
Me.DataGridView1.DataSource = d
Stephany Young wrote:
You need to convert the string to an array of characters:
Dim chararray As Char() = MyString.ToCharArray()
and then feed the array of characters to the Rows.Add method:
myDataTable.Rows.Add(chararray)
If you do not need to 'save' the interim result for another purpose then you
could feed it in directly:
myDataTable.Rows.Add(MyString.ToCharArray())
character
"Paulers" <Su*******@gmail.comwrote in message
news:11**********************@s34g2000cwa.googlegr oups.com...
Hello,
I have a string that I am trying to add each char to a datatable row.
for example if I have a string that looks like "abcdefg", I would like
to break it up into an array of characters so I can do this:
myDataTable.Rows.Add(array())
instead of myDataTable.Rows.Add("a","b","c","d","e","f","g")
You help is greatly appreciated!
thanks :)
Sorry, you can't do this directly with the Rows.Add method.
You have to do it indirectly, something like:
Dim d As DataTable = New DataTable
Dim line As String = "abcdefg"
For i As Integer = 0 to line.Length - 1
d.Columns.Add(New DataColumn("c" & i.ToString,
Type.GetType("System.Char")))
Next
Dim dr As DataRow = _d.NewRow()
dr.ItemArray = line.ToCharArray()
d.Rows.Add(_dr)
Me.DataGridView1.DataSource = d
"Paulers" <Su*******@gmail.comwrote in message
news:11*********************@l53g2000cwa.googlegro ups.com...
Hello and thanks for your response!
I gave that a try and when I display my DataGridView it shows
System.Char[] in the first col.
Here is what I did
Dim d As DataTable = New DataTable
Dim line As String = "abcdefg"
d.Rows.Add(line.ToCharArray())
Me.DataGridView1.DataSource = d
Stephany Young wrote:
>You need to convert the string to an array of characters:
Dim chararray As Char() = MyString.ToCharArray()
and then feed the array of characters to the Rows.Add method:
myDataTable.Rows.Add(chararray)
If you do not need to 'save' the interim result for another purpose then you could feed it in directly:
myDataTable.Rows.Add(MyString.ToCharArray()) character "Paulers" <Su*******@gmail.comwrote in message news:11**********************@s34g2000cwa.googleg roups.com...
Hello,
I have a string that I am trying to add each char to a datatable row.
for example if I have a string that looks like "abcdefg", I would like
to break it up into an array of characters so I can do this:
myDataTable.Rows.Add(array())
instead of myDataTable.Rows.Add("a","b","c","d","e","f","g")
You help is greatly appreciated!
thanks :)
Thank you Stephany!
I tried what you suggested and now on the line containing:
dr.ItemArray = line.ToCharArray()
I get an error messahe stating "Error 1 Value of type '1-dimensional
array of Char' cannot be converted to '1-dimensional array of Object'
because 'Char' is not a reference type."
Stephany Young wrote:
Sorry, you can't do this directly with the Rows.Add method.
You have to do it indirectly, something like:
Dim d As DataTable = New DataTable
Dim line As String = "abcdefg"
For i As Integer = 0 to line.Length - 1
d.Columns.Add(New DataColumn("c" & i.ToString,
Type.GetType("System.Char")))
Next
Dim dr As DataRow = _d.NewRow()
dr.ItemArray = line.ToCharArray()
d.Rows.Add(_dr)
Me.DataGridView1.DataSource = d
"Paulers" <Su*******@gmail.comwrote in message
news:11*********************@l53g2000cwa.googlegro ups.com...
Hello and thanks for your response!
I gave that a try and when I display my DataGridView it shows
System.Char[] in the first col.
Here is what I did
Dim d As DataTable = New DataTable
Dim line As String = "abcdefg"
d.Rows.Add(line.ToCharArray())
Me.DataGridView1.DataSource = d
Stephany Young wrote:
You need to convert the string to an array of characters:
Dim chararray As Char() = MyString.ToCharArray()
and then feed the array of characters to the Rows.Add method:
myDataTable.Rows.Add(chararray)
If you do not need to 'save' the interim result for another purpose then
you
could feed it in directly:
myDataTable.Rows.Add(MyString.ToCharArray())
character
"Paulers" <Su*******@gmail.comwrote in message
news:11**********************@s34g2000cwa.googlegr oups.com...
Hello,
I have a string that I am trying to add each char to a datatable row.
for example if I have a string that looks like "abcdefg", I would like
to break it up into an array of characters so I can do this:
myDataTable.Rows.Add(array())
instead of myDataTable.Rows.Add("a","b","c","d","e","f","g")
You help is greatly appreciated!
thanks :)
Well you have a couple of options:
Dim d As DataTable = New DataTable
Dim line As String = "abcdefg"
For i As Integer = 0 to line.Length - 1
d.Columns.Add(New DataColumn("c" & i.ToString,
Type.GetType("System.Char")))
Next
Dim dr As DataRow = _d.NewRow()
Dim o As Object() = new Object(line.Length -1) {}
For i As Integer = 0 to line.Length - 1
o(_i) = line.Chars(i)
Next
dr.ItemArray = o
d.Rows.Add(_dr)
Me.DataGridView1.DataSource = d
or:
Dim d As DataTable = New DataTable
Dim line As String = "abcdefg"
For i As Integer = 0 to line.Length - 1
d.Columns.Add(New DataColumn("c" & i.ToString,
Type.GetType("System.Char")))
Next
Dim dr As DataRow = _d.NewRow()
For i As Integer = 0 to line.Length - 1
dr(_i) = lone.Chars(i)
Next
d.Rows.Add(_dr)
Me.DataGridView1.DataSource = d
Either way, you need to deal with each character individually.
"Paulers" <Su*******@gmail.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
Thank you Stephany!
I tried what you suggested and now on the line containing:
dr.ItemArray = line.ToCharArray()
I get an error messahe stating "Error 1 Value of type '1-dimensional
array of Char' cannot be converted to '1-dimensional array of Object'
because 'Char' is not a reference type."
Stephany Young wrote:
>Sorry, you can't do this directly with the Rows.Add method.
You have to do it indirectly, something like:
Dim d As DataTable = New DataTable Dim line As String = "abcdefg" For i As Integer = 0 to line.Length - 1 d.Columns.Add(New DataColumn("c" & i.ToString, Type.GetType("System.Char"))) Next Dim dr As DataRow = _d.NewRow() dr.ItemArray = line.ToCharArray() d.Rows.Add(_dr) Me.DataGridView1.DataSource = d
"Paulers" <Su*******@gmail.comwrote in message news:11*********************@l53g2000cwa.googlegr oups.com...
Hello and thanks for your response!
I gave that a try and when I display my DataGridView it shows
System.Char[] in the first col.
Here is what I did
Dim d As DataTable = New DataTable
Dim line As String = "abcdefg"
d.Rows.Add(line.ToCharArray())
Me.DataGridView1.DataSource = d
Stephany Young wrote: You need to convert the string to an array of characters:
Dim chararray As Char() = MyString.ToCharArray()
and then feed the array of characters to the Rows.Add method:
myDataTable.Rows.Add(chararray)
If you do not need to 'save' the interim result for another purpose then you could feed it in directly:
myDataTable.Rows.Add(MyString.ToCharArray()) character "Paulers" <Su*******@gmail.comwrote in message news:11**********************@s34g2000cwa.googleg roups.com...
Hello,
I have a string that I am trying to add each char to a datatable
row.
for example if I have a string that looks like "abcdefg", I would
like
to break it up into an array of characters so I can do this:
myDataTable.Rows.Add(array())
instead of myDataTable.Rows.Add("a","b","c","d","e","f","g")
You help is greatly appreciated!
thanks :)
Stephany,
You are great! Thanks a million for your help. I hope some day I am as
knowledgable about vb.net as you are.
Stephany Young wrote:
Well you have a couple of options:
Dim d As DataTable = New DataTable
Dim line As String = "abcdefg"
For i As Integer = 0 to line.Length - 1
d.Columns.Add(New DataColumn("c" & i.ToString,
Type.GetType("System.Char")))
Next
Dim dr As DataRow = _d.NewRow()
Dim o As Object() = new Object(line.Length -1) {}
For i As Integer = 0 to line.Length - 1
o(_i) = line.Chars(i)
Next
dr.ItemArray = o
d.Rows.Add(_dr)
Me.DataGridView1.DataSource = d
or:
Dim d As DataTable = New DataTable
Dim line As String = "abcdefg"
For i As Integer = 0 to line.Length - 1
d.Columns.Add(New DataColumn("c" & i.ToString,
Type.GetType("System.Char")))
Next
Dim dr As DataRow = _d.NewRow()
For i As Integer = 0 to line.Length - 1
dr(_i) = lone.Chars(i)
Next
d.Rows.Add(_dr)
Me.DataGridView1.DataSource = d
Either way, you need to deal with each character individually.
"Paulers" <Su*******@gmail.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
Thank you Stephany!
I tried what you suggested and now on the line containing:
dr.ItemArray = line.ToCharArray()
I get an error messahe stating "Error 1 Value of type '1-dimensional
array of Char' cannot be converted to '1-dimensional array of Object'
because 'Char' is not a reference type."
Stephany Young wrote:
Sorry, you can't do this directly with the Rows.Add method.
You have to do it indirectly, something like:
Dim d As DataTable = New DataTable
Dim line As String = "abcdefg"
For i As Integer = 0 to line.Length - 1
d.Columns.Add(New DataColumn("c" & i.ToString,
Type.GetType("System.Char")))
Next
Dim dr As DataRow = _d.NewRow()
dr.ItemArray = line.ToCharArray()
d.Rows.Add(_dr)
Me.DataGridView1.DataSource = d
"Paulers" <Su*******@gmail.comwrote in message
news:11*********************@l53g2000cwa.googlegro ups.com...
Hello and thanks for your response!
I gave that a try and when I display my DataGridView it shows
System.Char[] in the first col.
Here is what I did
Dim d As DataTable = New DataTable
Dim line As String = "abcdefg"
d.Rows.Add(line.ToCharArray())
Me.DataGridView1.DataSource = d
Stephany Young wrote:
You need to convert the string to an array of characters:
Dim chararray As Char() = MyString.ToCharArray()
and then feed the array of characters to the Rows.Add method:
myDataTable.Rows.Add(chararray)
If you do not need to 'save' the interim result for another purpose
then
you
could feed it in directly:
myDataTable.Rows.Add(MyString.ToCharArray())
character
"Paulers" <Su*******@gmail.comwrote in message
news:11**********************@s34g2000cwa.googlegr oups.com...
Hello,
I have a string that I am trying to add each char to a datatable
row.
for example if I have a string that looks like "abcdefg", I would
like
to break it up into an array of characters so I can do this:
myDataTable.Rows.Add(array())
instead of myDataTable.Rows.Add("a","b","c","d","e","f","g")
You help is greatly appreciated!
thanks :) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mr.Clean |
last post by:
I have a string. I'd like to take this string
and make each char change until it gets to another
char at the same position of the string.
Example:
Original String: " NEW YORK "
Final...
|
by: Simon Schaap |
last post by:
Hello,
I have encountered a strange problem and I hope you can help me to
understand it. What I want to do is to pass an array of chars to a
function that will split it up (on every location where...
|
by: Chad Myers |
last post by:
I've been perf testing an application of mine and I've noticed that there
are a lot (and I mean A LOT -- megabytes and megabytes of 'em) System.String
instances being created.
I've done some...
|
by: Eric |
last post by:
Hi All,
I need to XOR two same-length Strings against each other. I'm assuming
that, in order to do so, I'll need to convert each String to a BitArray.
Thus, my question is this: is there an...
|
by: Daren |
last post by:
Hi,
I need to be able to split large string variables into an array of
lines, each line can be no longer than 70 chars.
The string variables are text, so I would additionally like the lines...
|
by: Niyazi |
last post by:
Hi all,
What is fastest way removing duplicated value from string array using vb.net?
Here is what currently I am doing but the the array contains over 16000
items. And it just do it in 10 or...
|
by: Christoph Scholtes |
last post by:
Hi,
I have two questions about the following code snippet. I am trying to
read in a series of strings and save them to character arrays. Since I
dont know how long my string is going to be (and...
|
by: Hugh Janus |
last post by:
Hi all,
I am using the below functions in order to convert strings to bytes and
vice versa. I totally ans shamefully stole these functions from this
group btw! Anyway, they work great but as...
|
by: ssecorp |
last post by:
char* reverse(char* str) {
int length = strlen(str);
char* acc;
int i;
for (i=0; i<=length-1; i++){
acc = str;
}
return acc;
}
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |