|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can't assign array! Beginner here.
Code:
Dim i As Integer
Dim wend1 As Boolean
Dim t1bits(50), str1 As String
Private Sub Text2_GotFocus()
wend1 = True
t1bits() = Split("a:s:d:f:g:h", ":")
i = 0
While wend1 = True
If Not t1bits(i) = "" Then
Text2.Text = Text2.Text & vbCrLf & t1bits(i)
Else
wend1 = False
End If
i = i + 1
Wend
End Sub
I get a can't assign to array error. I looked up the split() syntax in MSDN, and it says it returns an array. So isn't this how it works? No example to look sadly. I'm a PHP coder, and a transformation from PHP style coding to VB is kinda hard for me... ![]() I'm trying to make a flat file databased program. But if I can't even get to split the friggin file... ![]() Um... also anyone know any good resources to learn how to do database interaction in VB? I've heard Access is best with VB. I'm a total beginner, so dunno anything. I've done PHP/MySQL so I know database basics and stuff(SQL). |
|
#2
|
||||
|
||||
|
Try:
Code:
Dim t1bits
t1bits = Split("a:s:d:f:g:h", ":")
|
|
#3
|
|||
|
|||
|
If u read the msdn page seriously,U can find it:
Visual Basic Scripting Edition Split Function Returns a zero-based, one-dimensional array containing a specified number of substrings. Split(expression[, delimiter[, count[, compare]]]) Arguments expression Required. String expression containing substrings and delimiters. If expression is a zero-length string, Split returns an empty array, that is, an array with no elements and no data. delimiter Optional. String character used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned. count Optional. Number of substrings to be returned; -1 indicates that all substrings are returned. compare Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. Settings The compare argument can have the following values: Constant Value Description vbBinaryCompare 0 Perform a binary comparison. vbTextCompare 1 Perform a textual comparison. Remarks The following example uses the Split function to return an array from a string. The function performs a textual comparison of the delimiter, and returns all of the substrings. Dim MyString, MyArray, Msg MyString = "VBScriptXisXfun!" MyArray = Split(MyString, "x", -1, 1) ' MyArray(0) contains "VBScript". ' MyArray(1) contains "is". ' MyArray(2) contains "fun!". Msg = MyArray(0) & " " & MyArray(1) Msg = Msg & " " & MyArray(2) MsgBox Msg |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Can't assign array! Beginner here. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|