You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

1

Tuesday, August 21st 2012, 11:53am

MaxLength

Hi i need your help please i have a textbox called Text1 and i want to do something like this.
Text1.MaxLength=10
so i want to have a limit of the "username" textbox. How can i do it?

Thank you!

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

2

Tuesday, August 21st 2012, 6:51pm

Hey there,

have a look at this thread it might inspire you...

http://www.jabaco.org/board/p2953-keypre…r.html#post2953

Dani

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

3

Tuesday, August 21st 2012, 7:03pm

...that would be

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Option Explicit
   Implements java#awt#Event#KeyListener
Public Sub Form_Load()
   Text1.Parent.addKeyListener(Me)
End Sub

Public Sub keyTyped(arg2 As KeyEvent)
   If Len(Trim(Text1.Text))>= 10 Then arg2.setKeyChar(0)
End Sub

Public Sub keyPressed(arg2 As KeyEvent)
End Sub

Public Sub keyReleased(arg2 As KeyEvent)
   
End Sub


assuming you want to limit the input of a single control -> Text1

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

4

Tuesday, August 21st 2012, 10:50pm

Thank you very much for your help.
I did what exactly you told me but it returns
Class keyevent not found!

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

5

Wednesday, August 22nd 2012, 1:31pm

Hey there,

did you create a TextBox named Text1 in the UI designer?

When you press F1 a window called Imports appears. You can set references to external libraries here.
Go ahead and check if -> java#awt#Event#KeyListener is selected within the rt.jar
Usually this is done by Jabaco when you press the Start button for debugging!

When all that is present in your code editor the following Subs should be created:

Jabaco Source

1
2
3
4
5
6
7
8
Public Sub keyTyped(arg2 As KeyEvent)
End Sub

Public Sub keyPressed(arg2 As KeyEvent)
End Sub

Public Sub keyReleased(arg2 As KeyEvent)
End Sub


If that does not help save your project close Jabaco and start it again.
I am not sure what else would be required!?

Dani

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

6

Wednesday, August 22nd 2012, 4:02pm

none of the libraries is selected?
Do i have to select/import all?

This post has been edited 2 times, last edit by "fomaxrge" (Aug 22nd 2012, 4:14pm)


Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

7

Wednesday, August 22nd 2012, 4:22pm

Hey there,

as far as I know it should set the according references by itself!
You can try to set them manually or you can download the attached archive :D

Dani

KeyListener.zip

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

8

Wednesday, August 22nd 2012, 4:32pm

everything is working perfect!!!
But i din not put option explicit because i had some variable errors.
I checked them manually how could i use the zip you send me?
Just to know it

thank you very much!

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

9

Wednesday, August 22nd 2012, 4:56pm

simply extract the containing folder to some location on your system open it and doubleclick on 'KeyListener.jba'

got to work now ... have fun

Dani

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

10

Thursday, August 23rd 2012, 9:30am

thank you dani you helped me a lot.

Rate this thread
WoltLab Burning Board