[Gambas-user] TextBox and CR

Rolf-Werner Eilert eilert-sprachen at ...221...
Tue Apr 20 17:08:56 CEST 2010


No, don't worry :-)

So, this is my code now:

PUBLIC SUB Suche_KeyPress()
DIM t$ AS String

     IF Key.Code = Key.Return OR Key.Code = Key.Enter THEN
       t$ = Trim$(Suche.Text)
       IF t$ <> "" THEN
         SucheStarten(t$)
       END IF
     END IF

END

I introduced t$ (old BASIC manners, I know :-) ) to avoid calling trim 
for several times, and I feel it's shorter and reads easier. Then I set 
Key.Return first as it would be pressed more probably, and this routine 
is called for each key.

Later I realized that this is nonsense as it will check for Key.Enter 
with every key typed other than Return ;-) anyway...

Regards

Rolf


Am 20.04.2010 14:44, schrieb Caveat:
> Hi Rolf,
> I guess you're right.  I threw the code together very quickly, just to
> make a working example for you.  But 100% correct, you don't need lcode
> or AS Variant or DIM or lcode = Key.Code... :-)
>
> Let's just hope this doesn't turn into another marathon "static const?"
> thread ;-)
>
> Regards,
> Caveat
>
> On Tue, 2010-04-20 at 11:39 +0200, Rolf-Werner Eilert wrote:
>> Great, thanks!
>>
>> I just wonder why you load Key.Code into a variable before examining it
>> - isn't Key.Code a "variable" itself? (Or is it a function, and you
>> wanted to avoid calling it more than once?)
>>
>> Rolf
>>
>>
>> Am 20.04.2010 10:58, schrieb Caveat:
>>> Hi Rolf
>>>
>>> You could try this:
>>> PUBLIC SUB TextBox1_KeyPress()
>>>
>>>     DIM lcode AS Variant
>>>     lcode = Key.Code
>>>
>>>
>>>     IF NOT IsNull(lcode) THEN
>>>       IF lcode = Key.Enter OR lcode = Key.Return THEN
>>>         Message.Info("Go SEARCH buddy!")
>>>       END IF
>>>     END IF
>>>
>>>
>>> END
>>>
>>> Regards,
>>> Caveat
>>>
>>> On Tue, 2010-04-20 at 09:42 +0200, Rolf-Werner Eilert wrote:
>>>> Good morning everyone!
>>>>
>>>> In one of my programs there is a TextBox enabling the user to type in a
>>>> search word. The TextBox seems to ignore a Return at the end, so I chose
>>>> a "?" at the end of the string to indicate "go and search".
>>>>
>>>> It's a bit roundabout, however, isn't there a way to tell TextBox to
>>>> include a CR in the string when Return is pressed?
>>>>
>>>> This is the code now ("Suche" means "Search"):
>>>>
>>>> PUBLIC SUB Suche_Change()
>>>>
>>>>
>>>>      IF trim(Suche.Text) = "" THEN RETURN
>>>>
>>>>      IF String.Right(Suche.Text, 1)<>   "?" THEN RETURN
>>>>
>>>>      SucheStarten(Suche.Text)
>>>>
>>>> END
>>>>
>>>> Any easy way to make this react to a CR?
>>>>
>>>> Thanks for your ideas!
>>>>
>>>> Rolf
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Download Intel® Parallel Studio Eval
>>>> Try the new software tools for yourself. Speed compiling, find bugs
>>>> proactively, and fine-tune applications for parallel performance.
>>>> See why Intel Parallel Studio got high marks during beta.
>>>> http://p.sf.net/sfu/intel-sw-dev
>>>> _______________________________________________
>>>> Gambas-user mailing list
>>>> Gambas-user at lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Download Intel® Parallel Studio Eval
>>> Try the new software tools for yourself. Speed compiling, find bugs
>>> proactively, and fine-tune applications for parallel performance.
>>> See why Intel Parallel Studio got high marks during beta.
>>> http://p.sf.net/sfu/intel-sw-dev
>>> _______________________________________________
>>> Gambas-user mailing list
>>> Gambas-user at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> 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