[Gambas-user] Problem to use a TextArea
Fabien Bodard
gambas.fr at ...626...
Wed Apr 28 01:09:09 CEST 2010
it's utf8 use :
String.Instr instead Intr
http://gambasdoc.org/help/comp/gb/string/instr
2010/4/28 linus <linuxos at ...1896...>:
>
> Hi all,
>
> I'm using a TextArea in a little project like a Text Editor.
>
> When I add the part of code to search in the text of this TextArea, I
> have a problem during search text whith the command 'instr'.
>
> In fact, when this command find accented characters, it count 2
> characters instead of 1 and the position of the search at the end it
> false.
>
> Does any body have an explication about this problem please ?
>
> Joined the code to search in the TextArea
>
> ---------------------------------------------------------------------
>
>
> Public SAVMARKER as Interger
>
>
> Public Button1_Click()
>
> SearchTextInEditor(1)
>
> End
>
>
> PUBLIC SUB SearchTextInEditor(MODE AS Integer)
>
> ' MODE: 0 => From the beginning of the text
> ' MODE: 1 => After the last search
>
> DIM IndexCarac AS Integer
> DIM CaracTexte AS String
> DIM IndexRecherche AS Integer
> DIM LongueurRecherche AS Integer
>
> TextBox39.Text = Replace(TextBox39.Text, "\"", "")
> TextBox40.text = Replace(TextBox40.text, "\"", "")
>
> IF TextArea1.Length > 0 THEN
>
> IF TextBox39.text = "" THEN
> Message.Warning(("Please entrer text to search !"), ("Close"))
> RETURN
> END IF
>
> Application.Busy = 1
>
> SELECT CASE MODE
> CASE 0
> ' search from the beginning of the text
> SAVMARKER = 0
> IF ToggleButton5.Value = TRUE THEN
> ' Use the case sensitive
> IndexRecherche = InStr(TextArea1.Text, TextBox39.Text,
> SAVMARKER, gb.Text)
> ELSE
> ' No case sensitive
> IndexRecherche = InStr(Lower$(TextArea1.Text), Lower
> $(TextBox39.Text), SAVMARKER, gb.Text)
> END IF
>
> IF IndexRecherche > 0 THEN
>
> $TextEditor.Select(IndexRecherche - 1, Len(TextBox39.Text))
> $TextEditor.EnsureVisible()
> SAVMARKER = IndexRecherche + Len(TextBox39.Text)
> PRINT "IndexRecherche=" & IndexRecherche
> IF SAVMARKER > TextArea1.Length THEN
> SAVMARKER = TextArea1.Length
> END IF
>
> LongueurRecherche = Len(TextBox39.Text)
>
> ELSE
> Application.Busy = 0
> Message.Info(("Search finished. End of list attained."),
> ("Close"))
> RETURN
> END IF
>
> CASE 1
> ' Search following ...
> IF ToggleButton5.Value = TRUE THEN
> ' Use the case sensitive
> IndexRecherche = InStr(TextArea1.Text, TextBox39.Text,
> SAVMARKER, gb.Text)
> ELSE
> ' Ne pas tenir compte de la casse
> IndexRecherche = InStr(Lower$(TextArea1.Text), Lower
> $(TextBox39.Text), SAVMARKER, gb.Text)
> END IF
>
> IF IndexRecherche > 0 THEN
> TextArea1.Select((IndexRecherche - 1), Len(TextBox39.Text))
> SAVMARKER = IndexRecherche + Len(TextBox39.Text)
> IF SAVMARKER > TextArea1.Length THEN
> SAVMARKER = TextArea1.Length
> END IF
>
> ELSE
> Application.Busy = 0
> Message.Info(("Search finished. End of list attained."),
> ("Close"))
> RETURN
> END IF
> END SELECT
> END IF
>
> Application.Busy = 0
>
>
> END
>
> -----------------------------------------------------------------------------
>
> Thank you in advance.
>
> --
> Olivier CRUILLES
> Email: linuxos at ...1896...
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list