[Gambas-user] divide strings
BODARD Fabien
abidoo.too at ...11...
Mon Jan 27 00:33:53 CET 2003
Le Lundi 27 Janvier 2003 00:03, Jochen Georges a écrit :
> hello gambassies
>
> i still try to divide strings to make word-puzzles.
>
> i found Aray.FromString - ok, now i can divide a string in its
> words.
>
> but i still do not know how to divide it in its characters.
>
>
> does anyone know?
>
> thanks in advance
>
> beste gruesse
> jochen
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
> http://www.vasoftware.com
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
in code
--
PUBLIC FUNCTION DivideText (sText as String) as Array
Dim Index as Integer
Dim arDivText as New Array
For Index = 0 to Len(sText)
arDivText.Add Mid(sText, Index, 1)
Next
Return arDivText
END
I thing it work.... But if you have an out of bound in the Mid function...
Type :
For Index = 0 to Len(sText) - 1
This function return an array so in your main sub ... déclare an array
ex :(with a form named FTest with a button named 'Button1')
'//Code start here//
Dim §arGlobalText as New Array
STATIC PUBLIC SUB Main()
Dim hForm as Form
hForm = New FTest
hForm.Show
END
Public Sub Button1_Click()
Dim sVar as String
§arGlobalText = DivideText("Hello")
For Each sVar in §arGlobalText
Message.Info(sVar)
Next
END
PUBLIC FUNCTION DivideText (sText as String) as Array
Dim Index as Integer
Dim arDivText as New Array
For Index = 0 to Len(sText)
arDivText.Add Mid(sText, Index, 1)
Next
Return arDivText
END
'//Code finish Here//
i hope i've not made error... i've don't tested it....
Fabien
for your probleme with the open function...
PRIVATE inttext AS String
PUBLIC SUB _new()
intext = "hello" 'it's a file? so vérify the path... and use the exist()
function ...
END
PUBLIC SUB Button1_Click()
dim outexte as String
Open intext for read as #File
Read(#File, outtext)
Print outext
END
Fabien
More information about the User
mailing list