Re: Error:Value of type 'String' cant be converted to 1-dim array
I already tried this. but, it didn't work. Actually, Assets column is stored
as 1 dimensional array of Long in the database.
I wrote a function to do this:
Public Sub StringToArray(ByVal sThisString As String, ByVal asResults() As
Long, Optional ByVal sDelimRows As String = "ae", Optional ByVal sDelimCols
As String = "[]")
Dim lPos1dDel As Long, lLenString As Long, lColSepLen As Long
Dim lLastPos As Long, lThisRow As Long, lNumCols As Long, lThisCol
As Long, lRowSepLen As Long
lLenString = Len(sThisString)
If lLenString Then
lLastPos = 1
lPos1dDel = InStr(1, sThisString, sDelimRows)
'Dim StringCount As Integer 'The number of strings to output
'lNumCols = StringCount(sThisString, vbTextCompare)
lRowSepLen = Len(sDelimRows)
'If Not lNumCols Then
'Convert a 1D string
'Create buffer to store results
ReDim asResults(0 To Int(lLenString - 1 / 2))
lPos1dDel = InStr(lLastPos, sThisString)
Do While lPos1dDel
lThisRow = lThisRow + 1
asResults(lThisRow) = Mid$(sThisString, lLastPos, lPos1dDel
- lLastPos)
lLastPos = lPos1dDel
lPos1dDel = InStr(lLastPos, sThisString)
Loop
ReDim Preserve asResults(0 To lThisRow)
When I call asResults() in the following line, I get the error: Number of
indices is less than the number of dimensions of the indexed array
doc.LoadXml(EDP.ExportPositions(TextBox1.Text,
cmbStartDateandTime.SelectedText, cmbEndDateandTime.SelectedText,
asResults()))
"Onawole, Clement Oladapo" wrote:
[color=blue]
> clng(TextBox1.Text) should do
>
>
> "XML newbie: Urgent pls help!"
> <XMLnewbieUrgentplshelp@discussions.microsoft.co m> wrote in message
> news:922A88B1-CD62-42D2-9768-A38EF40D4933@microsoft.com...[color=green]
> > Hi,
> >
> > I am getting the error: Value of type 'String' cannot be converted to
> > '1-dimensional array of Long'.
> >
> > in the following line for TextBox2.Text field :
> >
> > doc.LoadXml(EDP.ExportPositions(TextBox1.Text,
> > cmbStartDateandTime.SelectedText,
> > cmbEndDateandTime.SelectedText, TextBox2.Text)))
> >
> > Actually, I have a webReference to ExportData.asmx file. Here, Assets
> > column has datatype as Long. Since the textbox I
> > created for Assets label has datatype string, this
> > is causing the problem.
> >
> > I tried all conversion types but it doesn't work. I appreciate your quick
> > help and thanku in advance.[/color]
>
>
>[/color]
|