473,411 Members | 1,895 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,411 software developers and data experts.

function to convert string to 1 dimensional array of long

function to convert string to 1 dimensional array of long in VB.Net
Feb 27 '06 #1
5 12682
function to convert string to 1 dimensional array of long in VB.Net


What do you expect that Long array to contain? Character codes? can
you give an example of the expected output for a given input?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Feb 27 '06 #2
Not exactly sure what you're after, but at a guess you have a comma-delimited
string in your xml file? And you want those values in an array of Long. If
that's the case:

(assume myNode is an XmlNode)

'get the comma-delimited string
'and split it into a string array
Dim temp() As String = myNode.InnerText.Split(",")

'convert the string array to an array of long
dim myLongArray() as long
temp.CopyTo(myLongArray, 0)

'continue processing with myLongArray

HTH

Richard

--

"XML newbie: Urgent pls help!" wrote:
function to convert string to 1 dimensional array of long in VB.Net

Feb 28 '06 #3
Richard,

I had the same idea as Mattias, with this question.

How can you put a string in a long. The only thing I can imaging is to put
every char from a string in a long array, however seems for me a little bit
without sense to convert a codetable depended Unicode datum to long.

Just my thought,

Cor
Feb 28 '06 #4
I am working on application that requires downloading data from the remote
databse by creating a refernce to it's web services.In my GUI, I have a
combobox for table name to query and the starttime and end time to get data
for.Let's suppose I want to query positions table, the function for that in
proxy class is mentioned below, where AssetList is an XML node containing a
list of one or more Assets.Assset is an XML node with the attribute of it's
unique id number.AssetID is the unique identification number of the asset.

This is the function
Public Function ExportPositions(ByVal SessionID As String, ByVal
StartDateTime As Date, ByVal EndDateTime As Date,
<System.Xml.Serialization.XmlArrayItemAttribute("A ssetID",
IsNullable:=false)> ByVal AssetList() As Long) As Position()
Dim results() As Object = Me.Invoke("ExportPositions", New Object()
{SessionID, StartDateTime, EndDateTime, AssetList})

Return CType(results(0),Position())

End Function
I am doing this for download button:

Private Sub btdownload_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btdownload.Click
'g_SessionID()

'Dim nsmgr As XmlNamespaceManager
'nsmgr = New XmlNamespaceManager(filterDoc.NameTable)

Dim EDP As ExportData.ExportDataWS
EDP = New ExportData.ExportDataWS

Dim doc As XmlDocument
doc = New XmlDocument

Dim node As XmlNode

Dim noderead As XmlNodeReader
noderead = New XmlNodeReader(node)

'Try
Dim elementnode As String
Dim nodecontents As String
doc.LoadXml(EDP.ExportPositions(cmbSelectdata.Sele ctedItem,
cmbStartDateandTime.SelectedText, cmbAsset.SelectedIndex))
For Each node In doc
While (noderead.Read())

If (noderead.NodeType = XmlNodeType.Element) Then

'string elementnode, nodecontents
nodecontents = noderead.ReadString()

If (nodecontents Is Nothing) Then

nodecontents = noderead.Value.ToString()
noderead.ReadOuterXml()

elementnode = noderead.Name
Label2.Text += elementnode + "-" + nodecontents +
"<br>"

End If

End If
End While

Next

My first question is: Can I query the methodGetPositions without creating a
combobox for tables? If yes, how.

If no, then I will be using combobox and it's text is in string then how can
I convert it into Long() and put it in the line:
doc.LoadXml(EDP.ExportPositions(cmbSelectdata.Sele ctedItem,
cmbStartDateandTime.SelectedText, cmbAsset.SelectedIndex))
I thanku all in advance for your time and pls reply asap.It's really urgent...

"XML newbie: Urgent pls help!" wrote:
function to convert string to 1 dimensional array of long in VB.Net

Feb 28 '06 #5
Just a quick note: cmbAsset is a combobox having the list of tables

Now, when I use this is in the following line, I get the error: string can't
be converted to an Array of Long

doc.LoadXml(EDP.ExportPositions(cmbSelectdata.Sele ctedItem,
cmbStartDateandTime.SelectedText, cmbAsset.SelectedIndex))
"XML newbie: Urgent pls help!" wrote:
I am working on application that requires downloading data from the remote
databse by creating a refernce to it's web services.In my GUI, I have a
combobox for table name to query and the starttime and end time to get data
for.Let's suppose I want to query positions table, the function for that in
proxy class is mentioned below, where AssetList is an XML node containing a
list of one or more Assets.Assset is an XML node with the attribute of it's
unique id number.AssetID is the unique identification number of the asset.

This is the function
Public Function ExportPositions(ByVal SessionID As String, ByVal
StartDateTime As Date, ByVal EndDateTime As Date,
<System.Xml.Serialization.XmlArrayItemAttribute("A ssetID",
IsNullable:=false)> ByVal AssetList() As Long) As Position()
Dim results() As Object = Me.Invoke("ExportPositions", New Object()
{SessionID, StartDateTime, EndDateTime, AssetList})

Return CType(results(0),Position())

End Function
I am doing this for download button:

Private Sub btdownload_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btdownload.Click
'g_SessionID()

'Dim nsmgr As XmlNamespaceManager
'nsmgr = New XmlNamespaceManager(filterDoc.NameTable)

Dim EDP As ExportData.ExportDataWS
EDP = New ExportData.ExportDataWS

Dim doc As XmlDocument
doc = New XmlDocument

Dim node As XmlNode

Dim noderead As XmlNodeReader
noderead = New XmlNodeReader(node)

'Try
Dim elementnode As String
Dim nodecontents As String
doc.LoadXml(EDP.ExportPositions(cmbSelectdata.Sele ctedItem,
cmbStartDateandTime.SelectedText, cmbAsset.SelectedIndex))
For Each node In doc
While (noderead.Read())

If (noderead.NodeType = XmlNodeType.Element) Then

'string elementnode, nodecontents
nodecontents = noderead.ReadString()

If (nodecontents Is Nothing) Then

nodecontents = noderead.Value.ToString()
noderead.ReadOuterXml()

elementnode = noderead.Name
Label2.Text += elementnode + "-" + nodecontents +
"<br>"

End If

End If
End While

Next

My first question is: Can I query the methodGetPositions without creating a
combobox for tables? If yes, how.

If no, then I will be using combobox and it's text is in string then how can
I convert it into Long() and put it in the line:
doc.LoadXml(EDP.ExportPositions(cmbSelectdata.Sele ctedItem,
cmbStartDateandTime.SelectedText, cmbAsset.SelectedIndex))
I thanku all in advance for your time and pls reply asap.It's really urgent...

"XML newbie: Urgent pls help!" wrote:
function to convert string to 1 dimensional array of long in VB.Net

Feb 28 '06 #6

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

Similar topics

2
by: DJ Craig | last post by:
I have 2-dimensional array with numeric indices for both dimensions, called $results, which contains the search results from a database. The first dimension contains the records, and the second...
0
by: Fabster | last post by:
Below is a code part I got somewhere and works fine for retrieving a version from a single file. Now I want to retrieve all .dll, .ocx and ..exe file versions from my harddisk in all directory's. I...
7
by: Hagge | last post by:
I'm stuck in a problem Hi I want to create a funtion in asp. Like this Then the function convert the "custom tag" to. <a href=www.mypage.com/user/Smith>Smith</a> How to do? I'm real...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
3
by: Alex Munk | last post by:
I would like to be able to pass a 2-dimensional array to a function as a string parameter. In the called function I would like to be able to convert the string back into a 2-dimensional array....
8
by: Klaas Vantournhout | last post by:
Hi all, I'm in need of a matrix of function pointers, and to be honest. No 'nice' solution has been found yet on that big big internet. It is possible to declare a matrix of function pointers...
4
by: Christian Maier | last post by:
Hi After surfing a while I have still trouble with this array thing. I have the following function and recive a Segmentation fault, how must I code this right?? Thanks Christian Maier
9
by: =?Utf-8?B?RGFya21hbg==?= | last post by:
Hi, I am wondering how you multi-dimension an array function? My declared function looks like this: Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long, ByVal Val3 As...
2
by: Jim | last post by:
I'm slowly switching over from VB6 to C# and need help converting an encrypted RC4 string to hex. The function below works perfectly within my vb6 app but I'm having difficulty finding a...
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: 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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.