Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 20th, 2003, 09:33 PM
Myth_Pharoah Myth_Pharoah is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Location: Pune, Maharashtra India.
Posts: 19 Myth_Pharoah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Myth_Pharoah
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).

Reply With Quote
  #2  
Old October 20th, 2003, 10:41 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Try:
Code:
Dim t1bits
t1bits = Split("a:s:d:f:g:h", ":")

Reply With Quote
  #3  
Old October 21st, 2003, 04:32 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Can't assign array! Beginner here.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT