Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old June 27th, 2003, 10:11 AM
jayrye715 jayrye715 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 35 jayrye715 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Question Locking and unlocking text boxes with code

I have a few textboxes that I need to set locked and greyed out and I need to also be able to change that with a command button. So what I need is for the user to see the information but not be able to change it. when the add button is clicked the user needs to be able to enter the information. Then when the update button is clicked it needs to lock the information back and grey it out. Is this possible to do. I am not sure how to code this. If anyone could show me how to do this with code it would be very helpful.

Let me thank you in advance for any help.

Reply With Quote
  #2  
Old June 27th, 2003, 10:18 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Code:
Private Sub addButton_Click()
    Me.txtSomeField.Enabled=True
End Sub

Private Sub updateButton_Click()
    Me.txtSomeField.Enabled=False
End Sub

Reply With Quote
  #3  
Old June 27th, 2003, 10:20 AM
jayrye715 jayrye715 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 35 jayrye715 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Will this also grey them out as well

Reply With Quote
  #4  
Old June 27th, 2003, 10:34 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
The text in it will be greyed out. If you want to have the field itself greyed out then you will have to set the backcolor property also.
i.e.
Code:
Private Sub addButton_Click()
    Me.txtSomeField.Enabled=True
    Me.txtSomeField.BackColor=vbWhite
End Sub

Private Sub updateButton_Click()
    Me.txtSomeField.Enabled=False
    Me.txtSomeField.BackColor=RGB(200,200,200)
End Sub

Reply With Quote
  #5  
Old June 27th, 2003, 10:35 AM
jayrye715 jayrye715 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 35 jayrye715 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Thumbs up

Thank you for your help.

Reply With Quote
  #6  
Old June 27th, 2003, 10:41 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Not a problem

Reply With Quote
  #7  
Old June 27th, 2003, 11:11 AM
jayrye715 jayrye715 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 35 jayrye715 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I need one more thing is there a way to keep the text black and not grey so it can be read

Reply With Quote
  #8  
Old June 27th, 2003, 11:45 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Just adjust the background color so that the grey is lighter
i.e. something like RGB(225, 225, 225)

You can also set the text to bold.

Last edited by Onslaught : June 27th, 2003 at 11:48 AM.

Reply With Quote
  #9  
Old June 27th, 2003, 12:02 PM
jayrye715 jayrye715 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 35 jayrye715 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I guess when you set the enable fuction to false It greys the text to. So I will play with it and see if I can make it where it will be viewable. Thanks again for your help. One more thing where can I find the Color skeem numbers.

Reply With Quote
  #10  
Old June 27th, 2003, 01:05 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
here is something that I found through google
http://www.hypersolutions.org/pages/rgbdec.html

Reply With Quote
  #11  
Old June 27th, 2003, 01:07 PM
jayrye715 jayrye715 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 35 jayrye715 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Thumbs up

Thank You for spending the time.

Reply With Quote
  #12  
Old June 27th, 2003, 01:09 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Your welcome

Reply With Quote
  #13  
Old June 28th, 2003, 08:26 PM
hedge hedge is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2002
Posts: 692 hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 21 h 49 m 55 sec
Reputation Power: 19
You can also also set the text box to be read/only via an api. this then allows them to cut/copy from it without disabling. Let me know if you would like the code.

Reply With Quote
  #14  
Old June 30th, 2003, 07:46 AM
jayrye715 jayrye715 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 35 jayrye715 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
That would be cool I would like for the user to be able to do that.

Reply With Quote
  #15  
Old June 30th, 2003, 03:03 PM
hedge hedge is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2002
Posts: 692 hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 21 h 49 m 55 sec
Reputation Power: 19
ok, here's the code although I just realized that it has been superseded by the .locked property, we must still have this remnant from older versions of VB. It still won't grey the text you'll have to do that manually.
PHP Code:
 Option Explicit
Const WM_USER = &H400
Const EM_SETREADONLY = (WM_USER 31)

Private Declare Function 
SendMessage Lib "user32" Alias "SendMessageA" (ByVal Hwnd As LongByVal wMsg As LongByVal wParam As LonglParam As Any) As Long

Sub control_readOnly
(meCtrl As ControlByVal readOnlyFlag As Long)

    
Dim rc As Long

    On Error Resume Next
    rc 
SendMessage(meCtrl.HwndEM_SETREADONLYreadOnlyFlag0&)
    
meCtrl.Locked = (readOnlyFlag <> False)
    
On Error GoTo 0
End Sub 

Reply With Quote