hey, I know most of you are Web Coders but Im wondering if anyone out there has some knowledge of vb...
anyway, Im trying to split up a string and plonk it in an array, of course, VB does this with the Split function, the only problem is that it returns an error "Cant assign to array" when I pre-define the array (Dim arry(1) As String). If the Array is assigned as a dynamic array (Dim arry() As String) then it all works fine, but I get a "Subscript out of range" error message when I check to see if arry(1) has anything in it or not.
So far the only way Ive figured to get around it is to use an "On error goto" statement, though I think thats a little shoddy and theres gotta be some way to get the Split function liking fixed arrays...
just for reference, my code looks like so...
Option Explicit
Dim p00p As String
Dim arry(1) As String
Private Sub cmdZoomIn_Click()
'Erase arry
p00p = ActiveWindow.RangeSelection.Address
arry = Split(p00p, ":", 2)
'On Error GoTo zoominerror:
If arry(1) <> "" Then
MsgBox arry(0)
MsgBox arry(1)
End If
'zoomcont:
'Exit Sub
'zoominerror:
' MsgBox "You need to select another number!"
'Resume zoomcont:
End Sub
as you can see, Ive commented out my error goto code and the "erase arry" statement (cause theyre both unnecesary).. any ideas?
I really hate it that I can't access the historical changes in my notes and if I accidentally delete large portions of the text which happens more often than not, sometimes, there's no recovering. There should always be a way to go backwards in time, simply because we have iCloud. And why is there no normal export capability? There should be a historical-change-back up and export capability.
Question
Novex
hey, I know most of you are Web Coders but Im wondering if anyone out there has some knowledge of vb...
anyway, Im trying to split up a string and plonk it in an array, of course, VB does this with the Split function, the only problem is that it returns an error "Cant assign to array" when I pre-define the array (Dim arry(1) As String). If the Array is assigned as a dynamic array (Dim arry() As String) then it all works fine, but I get a "Subscript out of range" error message when I check to see if arry(1) has anything in it or not.
So far the only way Ive figured to get around it is to use an "On error goto" statement, though I think thats a little shoddy and theres gotta be some way to get the Split function liking fixed arrays...
just for reference, my code looks like so...
as you can see, Ive commented out my error goto code and the "erase arry" statement (cause theyre both unnecesary).. any ideas?
Link to comment
https://www.neowin.net/forum/topic/86958-vb-split-function-and-arrays/Share on other sites
10 answers to this question
Recommended Posts