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?
-Drop the art style, it's cool but doesn't fit the franchise at all.
-Make it a gritty single player game, like Halo
-Include deathmatch and all that stuff, extraction can be a separate mode
If they don't do that, it's dead on arrival IMO.
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