Connecting Tech Pros Worldwide Forums | Help | Site Map

function to convert string to 1 dimensional array of long

XML newbie: Urgent pls help!
Guest
 
Posts: n/a
#1: Feb 27 '06
function to convert string to 1 dimensional array of long in VB.Net

Mattias Sjögren
Guest
 
Posts: n/a
#2: Feb 27 '06

re: function to convert string to 1 dimensional array of long


[color=blue]
>function to convert string to 1 dimensional array of long in VB.Net[/color]

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.
Richard Bysouth
Guest
 
Posts: n/a
#3: Feb 28 '06

re: function to convert string to 1 dimensional array of long


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:
[color=blue]
> function to convert string to 1 dimensional array of long in VB.Net[/color]
Cor Ligthert [MVP]
Guest
 
Posts: n/a
#4: Feb 28 '06

re: function to convert string to 1 dimensional array of long


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


XML newbie: Urgent pls help!
Guest
 
Posts: n/a
#5: Feb 28 '06

re: function to convert string to 1 dimensional array of long


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:
[color=blue]
> function to convert string to 1 dimensional array of long in VB.Net[/color]
XML newbie: Urgent pls help!
Guest
 
Posts: n/a
#6: Feb 28 '06

re: function to convert string to 1 dimensional array of long


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:
[color=blue]
> 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:
>[color=green]
> > function to convert string to 1 dimensional array of long in VB.Net[/color][/color]
Closed Thread