Solved

Border Property not responding to change

Posted on 2003-11-25
12
247 Views
Last Modified: 2010-05-03
Inside a Frame is a TextBox which I want to change the border property.  When I change the property
with  
TxtName.BorderStyle = 0  
it does not respond.  I assume something like the form, the frame, etc.
has to be refreshed?  No errors occur, but the border does not change.
0
Comment
Question by:dastaub
  • 4
  • 3
  • 3
  • +2
12 Comments
 
LVL 2

Expert Comment

by:rekhasri
ID: 9822966
In Which event are u trying to call this?
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 9822992
Hi!

Have you tried Refresh Method?

    Text1.BorderStyle = 0
    Text1.Refresh
    Frame1.Refresh
    Form1.Refresh


0
 
LVL 11

Accepted Solution

by:
dbrckovi earned 250 total points
ID: 9823021
Try setting BorderStyle property to 0 in property sheet (design view), and then in form_Load event set it back to 1.
Now it should work even without Refreshing.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9824272
?

I've no problem

Put textbox inside the frame


Private Sub Command1_Click()
TxtName.BorderStyle = IIf(TxtName.BorderStyle = 0, 1, 0)
End Sub
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 9824356
EDDYKT

The problem occurs if a textbox's appearence is flat, and if it's initial BorderStyle is None.
At least that's a condition under which it has happened to me.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9825222
It works in both cases

?->
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Expert Comment

by:MatrixFreak
ID: 9826228
dastaub,
     
        If the textbox settings are not as dbrckovi expained, then there are 2 other possible reasons that the textbox would behave that way. (1)The textbox name you typed in code does not match the original name you gave to the textbox visually (properties window) or (2) you accidentally created an array of textboxes by typing a number 0 in the index property of the properties window for the textbox. Reason (2) would change the textbox name from 'TxtName' to 'TxtName(0)' (or whatever number you might have entered) and that would cause the textbox to stop responding.  Goodluck!
0
 
LVL 1

Expert Comment

by:MatrixFreak
ID: 9826302
I just realized you said 'No errors occur'.  The reasons i gave would raise errors.  Unless you entered 'On Error Resume Next' in your code.  In that case the errors would go by unnoticed.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9826404
Create a new project and try
0
 
LVL 1

Expert Comment

by:MatrixFreak
ID: 9826599
EDDYKT,

        If you were asking me to 'Create a new project and try', i did.  It created no errors when the 'On Error Resume Next' was put the Form_Load, subroutine, or a command button.  However, errors did get raised when i realized that i forgot my installation does not automatically insert 'Option Explicit' in a new project and decided to type it in.  The 'Option Explicit' detected that there was a typo and said 'variable not defined'.  Dastaub might have the system setup to not Require Variable Declaration.  No 'Option Explicit' combined with 'On Error Resume Next' would create no errors.  Dbrckovis' reason is most likely, but mine is still a possibility.
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 9830118
This example should show what happens.

Create 4 textboxes, and two command buttons

Set appearance of textbox3 and textbox4 to 0
Set BorderStyle of textbox2 and textbox4 to 0

Paste this code to command buttons:
----------------------------------------------
Private Sub Command1_Click()
    Text1.BorderStyle = 1
    Text2.BorderStyle = 1
    Text3.BorderStyle = 1
    Text4.BorderStyle = 1
End Sub

Private Sub Command2_Click()
    Text1.BorderStyle = 0
    Text2.BorderStyle = 0
    Text3.BorderStyle = 0
    Text4.BorderStyle = 0
End Sub
-----------------------------------------------
Try clicking buttons.

Everything works fine except textbox3.

When textbox3.BorderStyle is 0 then it has black line around, and when it is set to 1 it gets a thicker black line.

I think this is a bug, and maybe it is fixed in some service pack.     My version of Visual Basic is 8176,    VBA: Retail 6.0.8169,    Forms3: 2.01
If you, EDDYKT, MatrixFreak, don't experience the same problem, and have new versions, then it's most likely a bug.    ( BTW I have never installed any servece pack )
0
 

Author Comment

by:dastaub
ID: 9846796
the problem appeared to dissappear when the property is set at design time to no border, then at run time I was able
to turn the borders off and on without any problem, as long as the borders are set to "0" at design time.
thank you.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now