|
-
Oct 4th, 2004, 07:42 AM
#1
Thread Starter
Lively Member
split function
why doesn't this work
VB Code:
Private Sub Command1_Click()
On Error Resume Next
Text2.Text = Split(ophalen, "seta")(Text3.Text - 1)
End Sub
Private Sub Form_Load()
Dim ophalen As String
Open "C:\Program Files\Call of Duty\Main\config_mp.cfg" For Input As #1
Input #1, ophalen
Text1.Text = ophalen
Close #1
End Sub
and i have an other problem
i want to split it with a gign that looks like an empty square
if i copy it and paste than i begin the next rule
how can i let cbscript know tht he must split it with this sign
he must get info from this file
http://www.davyquyo.be/config_mp.cfg
but when i try he give error
out of range
because of the empty squares
he only can read //generate by call of duty
Last edited by davyquyo; Oct 4th, 2004 at 09:46 AM.
-
Oct 4th, 2004, 08:01 AM
#2
Re: split function
Originally posted by davyquyo
why doesn't this work
VB Code:
Private Sub Command1_Click()
On Error Resume Next
[b]Text2.Text = Split(ophalen, "seta")(Text3.Text - 1)[/b]
End Sub
Highlighted line is not a valid syntax.
Also, when some text is splitted it becomes an array of values "located" between that character that you're splitting on.
Here is a quick sample for you:
VB Code:
Option Explicit
Private Sub Form_Load()
'==========================
Dim strFile As String
Dim varAllValues As String
Dim MyValues() As String
Dim i&
'provide full and valid path and file name
strFile = "c:\temp\test.txt"
Open strFile For Input As #1
'load entire file into a string variable
varAllValues = Input(LOF(1), #1)
Close #1
'in my test file delimeter is a carriage return, so
'I will split string based on it
MyValues() = SplitStringOnDelimiter(varAllValues, vbNewLine)
'you may now do anything you need to do with your data.
For i = 0 To UBound(MyValues) - 1 'this array is ZERO based
List1.AddItem MyValues(i)
Next i
End Sub
Public Function SplitStringOnDelimiter(varValues As Variant, _
varDelimiter As Variant) As Variant
SplitStringOnDelimiter = Split(varValues, varDelimiter, , vbTextCompare)
End Function
-
Oct 4th, 2004, 08:05 AM
#3
eek.. what is this Rhino.
-
Oct 4th, 2004, 08:13 AM
#4
Thread Starter
Lively Member
rhino
youre code shows now error but
but there are no values in list box
it's empty
-
Oct 4th, 2004, 08:16 AM
#5
Re: split function
Originally posted by davyquyo
... a gign that looks like an empty square ...
This could be a NULL character Chr(0) or Carriage Return Chr(13) or Linefeed Chr(10) or combination of char 10+13 ...
-
Oct 4th, 2004, 08:19 AM
#6
Originally posted by davyquyo
rhino
youre code shows now error but
but there are no values in list box
it's empty
??? That's just a sample for you that demonstrates HOW split() function works and NOT soomething that you can copy/paste. Be a little more creative in adapting someoneelse's code in your programs.
Cheers
-
Oct 4th, 2004, 08:20 AM
#7
Thread Starter
Lively Member
ok with chr(10) it worked
so i'think i can move on now
thanx a lot
-
Oct 4th, 2004, 08:21 AM
#8
Originally posted by Deepak Sakpal
eek.. what is this Rhino.
I usually don't respond to such useless posts but I will in this case:
OTHER THAN YEEEEEKING DO YOU HAVE TO OFFER ANYTHING AT ALL ???
-
Oct 4th, 2004, 08:22 AM
#9
Originally posted by davyquyo
ok with chr(10) it worked
so i'think i can move on now
thanx a lot
No problem.
-
Oct 4th, 2004, 08:52 AM
#10
Thread Starter
Lively Member
Originally posted by RhinoBull
??? That's just a sample for you that demonstrates HOW split() function works and NOT soomething that you can copy/paste. Be a little more creative in adapting someoneelse's code in your programs.
Cheers
i did copy past so i can see how it workbut i will change it little by little so i can go on with what i want so
i won't be using exactly the same script don't worry about that
thanx for the help
i appreciate it
-
Oct 4th, 2004, 09:08 AM
#11
Thread Starter
Lively Member
only one little question
how is this been written in vb "
i want to replace this to something else but i know i can't say
test=replace(ophalen, """, "something else")
-
Oct 4th, 2004, 09:15 AM
#12
Sure ...
Something like this will do the job:
VB Code:
Private Sub Command1_Click()
MsgBox "Good Monday Morning!"
MsgBox StrConv(Replace(UCase("Good Monday Morning!"), "MONDAY", ""), vbProperCase)
End Sub
-
Oct 4th, 2004, 09:17 AM
#13
Thread Starter
Lively Member
no i
i talking about this sign "
how do i replace this
-
Oct 4th, 2004, 09:43 AM
#14
Oh, sorry - it's a character 34 ... so here we go again:
VB Code:
Private Sub Command1_Click()
Dim strMsg$
strMsg = "Hello " & Chr(34) & "davyquyo" & Chr(34)
MsgBox Replace(strMsg, Chr(34), "'")
End Sub
-
Oct 4th, 2004, 09:46 AM
#15
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|