Odd TextBox Artifact: Underscore

Rufus Clupea

Board Regular
Joined
Feb 11, 2019
Messages
85
Hi Folks,

I have a TextBox/SpinButton Combo that works fine, except that I notice an odd artifact when directly/manually changing the (numerical) value in the TextBox... It acquires an Underscore during input. This does not happen when changing the value via the SpinButton. :confused:

The underscore appears across the entire bottom of the TextBox—not just under the characters being input.

I tried making the font smaller to try to see what's going on, but when I do that, the underscore does not appear; it only appears when the font (Times New Roman 18 pt. Bold) is full size, whether bolded or not. TextBox is 30 x 24.

Any thoughts?

TIA
 
Last edited:

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
You could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0
In preparing a generic version, it became apparent that the problem isn't that involved.

Here's the code:

Code:
Sub SpinButton1_Change()
    TextBox1.Value = SpinButton1.Value
End Sub

Sub TextBox1_Change()
    If Len(TextBox1.Value) = 1 Then Exit Sub
End Sub

Sub TextBox5_AfterUpdate()

    If Val(TextBox1.Value) < SpinButton1.Min Then
        TextBox1.Value = SpinButton1.Min
    End If
    
    If Val(TextBox1.Value) > SpinButton1.Max Then
        TextBox1.Value = SpinButton1.Max
    End If
    
    SpinButton1.Value = TextBox1.Value
    
End Sub

A simple (default size) UserForm with a 30w x 24h TextBox (Times New Roman 18 Bold; Text: 18) and a SpinButton (Max 55; Min 15; Value 18) reproduces the artifact. Click on the TextBox (highlighting the text) and input any number 15 >= X <= 55. The artifact appears when the 2nd digit is keyed.
 
Upvote 0
I just noticed an error. In copy/pasting, I missed changing the 5 to a 1 in the last Sub. However it doesn't seem to affect the anomaly either way...
 
Upvote 0
What happens is that the letter does not fit in the textbox, if you increase the height of the textbox to 27, you will notice that the "artifact" no longer appears.
 
Upvote 0
This kind of begs a few (rhetorical) questions:

  • Why doesn't it occur on the first character keyed?
  • Why doesn't it occur when the value is changed via SpinButton?
  • Why isn't it mentioned/documented ANYWHERE? (I've been searching for hours—both before & after posting)?
I guess it does explain why it doesn't happen when the font is made smaller.

mumble-mumble grumble-grumble mumblety-grumblety friggin' microsquish....


After playing around sommore, it looks like 25.5 high will do it (autosizing). meh.
 
Last edited:
Upvote 0
You put rhetoric, but I would like to answer.


Why does not it occur on the first character keyed?
The cursor fits.

Why does not it occur when the value is changed via SpinButton?

The cursor is not inside the textbox

Why is not it mentioned / documented ANYWHERE? (I've been searching for hours-both before & after posting)?
This could be the first document (there is always a first time)

I guess it does explain why it does not happen when the font is made smaller.
Exactly, with the smaller letter the cursor fits in the textbox.

:)
 
Upvote 0
You put rhetoric, but I would like to answer.
That's fine—no pressure.

Why does not it occur on the first character keyed?
The cursor fits.
Mmmm... I don't follow. That would suggest the problem is horizontal. If/when the box is expanded very wide horizontally, the underscore still appears, so the problem should be, as you said previously, with the height. However, then the first character keyed should also produce the underscore. No? :confused:
 
Upvote 0
That's fine—no pressure.


Mmmm... I don't follow. That would suggest the problem is horizontal. If/when the box is expanded very wide horizontally, the underscore still appears, so the problem should be, as you said previously, with the height. However, then the first character keyed should also produce the underscore. No? :confused:


From what I see, the problem is when the cursor, in this case, the cursor size reaches the end of the textbox.
 
Upvote 0
From what I see, the problem is when the cursor, in this case, the cursor size reaches the end of the textbox.
That's just it. As I explained above, "If/when the box is expanded very wide horizontally, the underscore still appears..."
The cursor is still far to the left of the right-hand side of the TextBox.

I spoze it's academic/moot at this point; increasing the height 1.5 pts. seems to have solved the problem without changing the width.

Thanks again.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top