Important alert: (current site time 7/16/2013 12:48:57 AM EDT)
 

VB icon

!Make the textbox Locked for inputs and NOT grey!

Email
Submitted on: 8/10/1999
By: Martin Tonek 
Level: Not Given
User Rating: By 60 Users
Compatibility: VB 5.0, VB 6.0
Views: 95867
 
     Let you lock your textbox for inputs and it will NOT be grey, but will be able to highlightning and scrolling. One line code is all you need!
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: !Make the textbox Locked for inputs and NOT grey!
' Description:Let you lock your textbox for inputs and it will NOT be grey, but will be able to highlightning and scrolling. One line code is all you need!
' By: Martin Tonek
'
' Inputs:add a textbox named Text1.
Thats IT!!
'
' Returns:A textbox that you can highlight and scroll but not change
'
' Assumes:None, More simple then this it will never be!
well if you cant see all text.. just change multiline to true in textbox
properties. But that you already now!! ;-)
More sources avalible on http://hem.passagen.se/tonek/vb
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=2894&lngWId=1'for details.'**************************************

'// Please visit my homepage http://hem.passagen.se/tonek/vb
'// and check out other sources i made..
'// Martin Tonek <tonek@hem.passagen.se>
Private Sub Form_Load()
'// This will lock the control so you cant make any changes
'// in runmode , false open it up.. default is false
Text1.Locked = True
Text1.Text = "you can scroll and highlight the text in the control" & _
" but you can't edit it. The program can still modify the text by " & _
"changing the Text property"
End Sub
'// I find it in the helpfile...so now you now how. Also want to add that
'// all people using the keyascii code.. this one is better...
'// neet little code free to use
'// Wonder why people is so upset. I just tell this one..
'// so a lot of people that do not use it when it is avalible may use it.


Other 6 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
8/11/1999 1:15:00 AMBARRYR

I think this was worth posting as I have been looking at performing similar results myself, up until now I had been assigning the KeyAscii value within the Keypress event to 0.
(If this comment was disrespectful, please report it.)

 
8/11/1999 10:05:00 PMCarlos

Well i think this is a good move to have put your
discover onto the site, plus, sometime many people
don't have a good knowledge of VB, after all VB
is a verry Basic progamming language, as his name.

Continue to work on !! go to my Advanced code if you which too !!
Submitted By Carlos.

Thanks.
(If this comment was disrespectful, please report it.)

 
12/20/1999 8:43:37 AMRobert Carter

Just wanted to say thanks for the post, ive been using VB for a while and for some reason never found out about this, and have been setting the keyAscii = 0 also, so thanx for the post
(If this comment was disrespectful, please report it.)

 
2/17/2000 6:46:29 AMBurbble

Heh heh. Isn't "Lock" one of a text box's properties?
(If this comment was disrespectful, please report it.)

 
2/17/2000 6:47:10 AMBurbble

oops, wrong button! ...That is visible in the box on the side? :)
(If this comment was disrespectful, please report it.)

 
3/1/2000 7:49:37 AMKevin

Locked
Is a standard function of a textbox, your right burbble !
In the options dialog of a text control you only need to set the locked function to TRUE
(If this comment was disrespectful, please report it.)

 
4/15/2000 1:17:40 AMICERAPIDS

This.. is really useful.. but only to those people who.. dont know where the "VB Properties" window is.. so next time try looking at the properties of any control.. before you make yourself look bad.
(If this comment was disrespectful, please report it.)

 
8/10/2000 8:02:29 PMDoofah

Forgive me if I'm wrong - but using locked in the Properties Window makes the text box grey....

Calling Text.Locked = True in the proggy doesn't... so although this isn't nuclear physics - he ain't looking like a fool!
(If this comment was disrespectful, please report it.)

 
9/28/2000 11:35:48 AMDoofah

Thats "Enabled" not "Locked"

So, no you're not forgiven. ;-)
(If this comment was disrespectful, please report it.)

 
11/30/2000 9:17:32 AMSyed

Good thought cos i never think of that before this.
(If this comment was disrespectful, please report it.)

 
5/24/2001 2:21:32 PMnit3shift

Okay this just plain simple. :( you people should know how to do this stuff.
(If this comment was disrespectful, please report it.)

 
6/19/2001 11:16:13 PMMark Lu

I used to thought VB wasn't powerful because I didn't know too much about uncommonly used properties and functions. Now I know abot a lot, I am already Advanced in VB. Even though, this would be good for newbies. I used to have the same problems until I found out about the 'Locked' property.
(If this comment was disrespectful, please report it.)

 
1/1/2002 8:30:27 PMsinging flea

Well Martin,
All I can say is WOW!
Your submission has
been accessed 18,541 times
as of this posting!
And 26 people have taken
the time to vote! Good or bad.
Most submissions,
even contest winners,
do not get this kind of
acknowledgement.
Simply awesome!:o)

(If this comment was disrespectful, please report it.)

 
5/16/2002 2:21:22 PMJohn Clark

Makes me glad I took the time to register to this site. Hey guys!!! A great new tip I just learned, only took me 5 years!! If you set the visible property of a control to "False", you won't see it at run-time!!!
(If this comment was disrespectful, please report it.)

 
5/17/2002 9:25:39 AMJay

This isn't a trick it's a property. Whats next how to change the background color of the textbox?
(If this comment was disrespectful, please report it.)

 
6/10/2002 8:42:23 PMbond

umm...this is basic code. you learn this when you start learning VB, so its not special code.
(If this comment was disrespectful, please report it.)

 
6/17/2002 11:34:51 AMBrain

The code to change the color of a text box is to complicated for you fools. ha ha. but here it is anyway don't get a headache trying to read it.

text1.backcolor=RGB(int(rnd*256),int(rnd*256),int(rnd*256))
Whoa!!
(If this comment was disrespectful, please report it.)

 
6/17/2002 11:37:10 AMBrain

Sorry, i was just beeing a little sarcastic.
but the code is a fine discovery to make and when a discovery is made sometimes people post it to help younger coders not to be ridiculed by fools.
(If this comment was disrespectful, please report it.)

 
7/7/2002 7:32:59 PMXio

Saw that on an app and didnt figured out how to do. Helped me.
Thanks.
(If this comment was disrespectful, please report it.)

 
7/21/2002 6:30:25 PMCrypt

A small piece of code like this has helped me so much, thanks.
(If this comment was disrespectful, please report it.)

 
7/29/2002 9:50:26 AMNexz

*sigh* Locked does not make the textbox gray and its a property... OK?
(If this comment was disrespectful, please report it.)

 
9/23/2002 7:00:02 PM

That is a nice code for begginers....i'll show some people how to remove the * from a password box!!!
(If this comment was disrespectful, please report it.)

 
9/28/2002 10:34:30 PMJohn C Kirwin

Text1.Locked = True is perfect for a good idea - Karoke (cool, I'm off to my next project thanks!).
(If this comment was disrespectful, please report it.)

 
10/11/2002 4:03:08 PMGWMorris

Ya reckon that a lot of these "replies" maybe.. Uhmm.. came from the poster itself? Nahh.. too radical an idea.
Look, if the concept of a properties window is too much for your brain, you might consider another activity. Press F2 sometime, just for fun. Oh, darn, I just gave away my closely guarded secret on how to find (guess what?) LITTLE USED PROPERTIES! (and methods, and ....)
(If this comment was disrespectful, please report it.)

 
1/18/2003 9:30:22 PM

Well its like submitting "How to make a textbox!"
(If this comment was disrespectful, please report it.)

 
2/13/2003 6:57:43 AM

In all my 69 years of programming I neither noticed nor explored the purpose of this property... thanx for posting the tip.

Five globes to offset the hate/envy brigade venting here.
(If this comment was disrespectful, please report it.)

 
2/26/2003 8:11:11 PMDavid Liu

its a basic thing..even a newbie would know that
(If this comment was disrespectful, please report it.)

 
4/12/2003 9:23:49 PMMichael Batrich

Paaaahleeeeeese.....
I visit this site to pick up tips from code hacks like myself, and I get a "chapter 1" lesson????
I Just have four letters for ya: R-T-F-M!
I'm posting "five" to keep your confidence up and keep trying!!!!!!!!!
(If this comment was disrespectful, please report it.)

 
5/15/2003 10:36:11 PMhyrichter

Hey, if it helps someone, great! Ya, most of us know about the properties of a text box, but don't give him a hard time for helping out some newbies! You were all once new to VB...
(If this comment was disrespectful, please report it.)

 
6/30/2003 8:31:33 PMWolf McCloud

ew, if people didn't know that, they were total newbies or just dumb. it is in the textbox properties
(If this comment was disrespectful, please report it.)

 
6/30/2003 8:32:45 PMWolf McCloud

hyrichter, even when i was a n00b, i searched for ways of making things, and i tried every property, programming/hacking is knowing, and to know you need to find by yourself because this will work better
(If this comment was disrespectful, please report it.)

 
9/29/2003 12:47:40 AMKalyana Kumar

Excellent piece of work.My vote is for you.Keep up the good work.Well
deserved 5 globe from me.Thanks for sharing.Why i vote , is because even though the code is small bu tyou were willing to share it with us.Thats why.
I have also uploaded my first submission i would like everyone to review it and vote for as it deem suitable. Thank you.You can access my submission at:

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=48683&lng WId=1

I
would appreciate your vote as i am considering to highlight this submission in my CV.

Thank you yet again.

Kalyana Kumar
(If this comment was disrespectful, please report it.)

 
10/17/2003 9:36:33 PM

thi is good code
(If this comment was disrespectful, please report it.)

 
3/2/2004 3:16:11 AM

Need to know how to write a program by VB
(If this comment was disrespectful, please report it.)

 
4/21/2004 12:32:13 AMGrayda

Next, try making a textbox that won't turn grey, and not allow you to highlight. That's more advanced code
(If this comment was disrespectful, please report it.)

 
4/27/2004 2:05:15 AM

I thought this is something else. But... hehhehe.... good effort. Submit more... Be sure something serious. You must be joking right?
(If this comment was disrespectful, please report it.)

 
5/16/2004 7:30:58 AMDemigod

To all giving this person a hard time: Where did you folks start out? Sure this is basic stuff, but it HAS helped some people. IMO, this is all that counts.
(If this comment was disrespectful, please report it.)

 
5/16/2004 7:32:18 AMDemigod

Oh, and BTW I learned this the very first day I used VB, so don't go around calling me dumb.
(If this comment was disrespectful, please report it.)

 
5/24/2004 11:29:02 PM

HAHAHA

(If this comment was disrespectful, please report it.)

 
5/27/2004 8:30:48 PM

Look everyone, it`s obvious that this is a very basic bit of information, but there could still be people who know not of this.
If you see this as something foolish or such, simply leave the post be, there`s no need to diss anyone about it. Especially not the one who posted it, for he only helped others by doing so.
(If this comment was disrespectful, please report it.)

 
7/23/2004 6:53:39 AMJeroen van de Ven

This isn't code, it's a control's property.

It's not Planet VB Guide.com
(If this comment was disrespectful, please report it.)

 
10/25/2004 6:13:23 AM

pisot
(If this comment was disrespectful, please report it.)

 
11/18/2004 11:15:27 AM

Hey!! i never use this yet such programs that i made..will i'm goin to try this one..keep posting a codes this will help us a lot such learning and keeping our talents flow..
(If this comment was disrespectful, please report it.)

 
3/15/2005 12:58:13 AMNoel A. Dacara

Forgive me but I have to say this...
This submission is for lamers only.
(If this comment was disrespectful, please report it.)

 
3/24/2005 1:19:04 AMCHUBBZonDUBBZ

This is the most basic thing I have ever seen, Good you found a property.

In .NET it's .READONLY, but whatever
(If this comment was disrespectful, please report it.)

 
3/30/2005 7:13:38 PM

im new and this was helpful, thanks, whateva anyone says
(If this comment was disrespectful, please report it.)

 
4/28/2005 6:41:23 PMWilliam -

this is to simple to be posted....really even a noob could figure this out, with no help at all


(If this comment was disrespectful, please report it.)

 
7/17/2005 5:59:44 PMRciX

Lol, wow.. this is so simple, yet it got so many replies/votes, doesn't anyone know there's a properties window???
(If this comment was disrespectful, please report it.)

 
1/14/2006 4:24:39 PMErik

Nyttig tips!

(Good Tips)
(If this comment was disrespectful, please report it.)

 
1/24/2006 4:06:12 AMWawan

planetsourcecode

(If this comment was disrespectful, please report it.)

 
5/4/2006 2:39:23 AM4th0rD!@

nice codes!!
i want more..

(If this comment was disrespectful, please report it.)

 
5/11/2006 10:34:02 AMLT sK8eR2gO

This was extremely lame.
(If this comment was disrespectful, please report it.)

 
5/14/2006 5:19:57 AMAbdullha

Nothing
(If this comment was disrespectful, please report it.)

 
5/14/2006 5:21:35 AMAbdullha

my name abdullha i'm from world
(If this comment was disrespectful, please report it.)

 
6/7/2006 1:30:03 PMMICRO-CODER

Ok people. Say what you want, but blow me anyway. I have been doing professional programming for about 9 years now...(vb6 = 6 years, VB.NET = 3)

Professional meaning I make 63K a year for it.

First off, I NEVER realised that hard coding that value for that property would NOT grey it out, all of you smart asses that say "RTFM" and "Look at the properties window" really shows how much of a "NOOB" you are.

You don't criticize code, no matter how small, short or useless YOU may think it is. The essence of this site is to promote ideas, help out and possibly make money on Rent-A-Coder.
(If this comment was disrespectful, please report it.)

 
6/7/2006 1:31:00 PMMICRO-CODER

Talk all the craap you want (those who criticize) but the fact that you VIEWED this post means 1 of 2 things:

1: You didn't know how to do it, then realising how easy, and wondering how you missed it - you decide to criticize it.

or

2: You saw this post and viewed it for the sole purpose of "racking" on someone for something you already knew.

What the hell is wrong with you? A TOTAL NEWBIE wouldn't know the difference between a variable and a control to save whale.
(If this comment was disrespectful, please report it.)

 
7/22/2006 1:34:42 AMJason Curtius

Not knocking your work but you could avoid negitive comments by simply putting 'beginer' level with your work.
That way you attract the people who need this. Sorry but no vote from me.
(If this comment was disrespectful, please report it.)

 
9/6/2006 1:34:34 AMAmy

simple... but very helpfull... :-)
(If this comment was disrespectful, please report it.)

 
11/15/2006 11:42:35 PMvanggol

we all know that!
(If this comment was disrespectful, please report it.)

 
12/20/2006 11:24:10 PMDolphin

Hey, this looks simple yet powerful ... Thanks for the person who submitted this ... Good Work Man/Lady ... :) I want to use this statement in my programs ... Once again, Thanks ... !!! Good Work and Good Luck.
(If this comment was disrespectful, please report it.)

 
3/15/2007 6:55:54 PMHardStream Software Development

OMG not again! I thought that the time of spamming PSC with .= was over I guess I was naïve ;(
(If this comment was disrespectful, please report it.)

 
3/24/2007 12:17:44 AMkishore

thank's to the wonderful line that has the ability to work a lot, you have great future. I wish you all the best for sharing the work you have done. Good work.
(If this comment was disrespectful, please report it.)

 
4/17/2007 6:15:54 AMrobail

it is very good to join this site
(If this comment was disrespectful, please report it.)

 
8/5/2007 5:52:52 AMOliver

oh come on. the value Locked is a property. if you want it to lock on Form_Load why not just set it to True in the first place =/
(If this comment was disrespectful, please report it.)

 
10/8/2007 8:56:14 AMein?

it's a joke?
(If this comment was disrespectful, please report it.)

 
3/3/2008 6:08:27 AMJoe

Hi can i get help on mu coding.... My modify is not working.... and Sorting also
(If this comment was disrespectful, please report it.)

 
3/16/2008 11:40:41 PMjoey

hey... i can make a textbox not grey but you cannot enter text or highlight...lol! ... paste the textbox inside a picture box then set the property of the picture box to enable=false...or code picturebox1.enable=false ... that would amaze the newbies!
(If this comment was disrespectful, please report it.)

 
8/2/2008 2:49:55 PMadamzz

Lol or just change Locked to True in the design tab -.-'
(If this comment was disrespectful, please report it.)

 
8/30/2008 5:34:13 AMnewguy13

Well,what can I say?
To an expert this is dumb but to a beginner it is a new and important lesson learnt.

(If this comment was disrespectful, please report it.)

 
10/11/2008 4:47:02 AMJACOB, WUNUDE LUCKY

Interesting
(If this comment was disrespectful, please report it.)

 
1/2/2009 2:39:48 AMalwi

this pages is good idea, thanks
(If this comment was disrespectful, please report it.)

 
1/22/2010 12:19:16 AMinfoharunbd

good
(If this comment was disrespectful, please report it.)

 
6/25/2010 11:09:40 PMheriyanto

carikan contoh vb dalm mengolah citra
(If this comment was disrespectful, please report it.)

 
10/2/2010 10:01:42 PMjonz

i like planet source code
(If this comment was disrespectful, please report it.)

 
8/19/2011 1:46:19 AMNitesh shrestha

That sounds intresting

(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.