?
Solved

Upper case in text box

Posted on 2010-09-14
8
Medium Priority
?
733 Views
Last Modified: 2012-05-10


Private Sub Calendar1_Click()

TextBox1.Text = Format(Calendar1.Value, "mm/dd/yy")
    'inserts date into textbox1


End Sub

Private Sub CkBoxIncoming_Click()

End Sub

Private Sub CmdBtnCloseForm_Click()

Unload Me        'removes form from spreadsheet with cmd btn.

End Sub

Private Sub CommandButton1_Click()

    'inserts textbox data into spreadsheet fields.

Dim r As Range
Set r = Range("A40").End(xlUp)      'a65536
Set r = r.Offset(1, 0)
r.Value = TextBox1.Value
Set r = r.Offset(0, 1) 'moves right with each "1".
r.Value = TextBox2.Value
Set r = r.Offset(0, 1)
r.Value = TextBox3.Value
Set r = r.Offset(0, 1)
r.Value = TextBox4.Value
Set r = r.Offset(0, 1)
r.Value = CkBoxIncoming.Value

How do I force capital letters into the above text boxes?

How do I write the code in a better fashion with all the value lines?  e.g. with or select?
0
Comment
Question by:1r3o2n8
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 13

Expert Comment

by:MWGainesJR
ID: 33675563

Private Sub Calendar1_Click()

TextBox1.Text = Format(Calendar1.Value, "mm/dd/yy")
    'inserts date into textbox1


End Sub

Private Sub CkBoxIncoming_Click()

End Sub

Private Sub CmdBtnCloseForm_Click()

Unload Me        'removes form from spreadsheet with cmd btn.

End Sub

Private Sub CommandButton1_Click()

    'inserts textbox data into spreadsheet fields.

Dim r As Range
Set r = Range("A40").End(xlUp)      'a65536
Set r = r.Offset(1, 0)
r.Value = ucase(TextBox1.Value)
Set r = r.Offset(0, 1) 'moves right with each "1".
r.Value = ucase(TextBox2.Value)
Set r = r.Offset(0, 1)
r.Value = ucase(TextBox3.Value)
Set r = r.Offset(0, 1)
r.Value = ucase(TextBox4.Value)
Set r = r.Offset(0, 1)
r.Value = CkBoxIncoming.Value

Open in new window

0
 

Author Comment

by:1r3o2n8
ID: 33675816
That works great.  Thanks alot.  
In that area of code where you made the ucase corrections, is there a way to recode it, perhaps with a "with" statement, that will reduce the amount of code?
0
 
LVL 13

Expert Comment

by:MWGainesJR
ID: 33675934
No but you can do this which is even more efficient
on error resume next
Dim r As Range
dim ws as worksheet
set ws = activesheet
Set r = ws.Range("A" & ws.Range("A40").End(xlUp).row + 1 & ":E" & ws.Range("A40").End(xlUp).row + 1)      'a65536  
for each c in r
c.Value = ucase(me.controls("TextBox" & c.column).value)
next

Open in new window

0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 13

Expert Comment

by:MWGainesJR
ID: 33675969
Actually use this, don't use A40
on error resume next  
Dim r As Range  
dim ws as worksheet  
set ws = activesheet  
Set r = ws.Range("A" & ws.Range("A" & ws.range("A:A").rows.count).End(xlUp).row + 1 & ":E" & ws.Range("A" & ws.range("A:A").rows.count).End(xlUp).row + 1)      'a65536    
for each c in r  
c.Value = ucase(me.controls("TextBox" & c.column).value)  
next

Open in new window

0
 
LVL 13

Expert Comment

by:MWGainesJR
ID: 33676011
oops, I looked over your combobox.....check the below code of the fix.....
on error resume next    
Dim r As Range    
dim ws as worksheet    
set ws = activesheet    
Set r = ws.Range("A" & ws.Range("A" & ws.range("A:A").rows.count).End(xlUp).row + 1 & ":D" & ws.Range("A" & ws.range("A:A").rows.count).End(xlUp).row + 1)      'a65536      
for each c in r 
if c.column <> r.cells.count then  
c.Value = ucase(me.controls("TextBox" & c.column).value)
else
c.value = CkBoxIncoming.Value
end if
next

Open in new window

0
 

Author Comment

by:1r3o2n8
ID: 33676601
Your code did the job!  May I have an explanation of lines 5-8??
0
 
LVL 13

Accepted Solution

by:
MWGainesJR earned 500 total points
ID: 33677747
It sets r to the range that you are filling and then loops through each cell. Because each column is mapped to the textbox number (column 1 to textbox1 etc) it can set the values dynamically. Just be careful when adding and subtracting columns/textboxes and renaming textboxes. You'll have to edit code with it.
0
 

Author Closing Comment

by:1r3o2n8
ID: 33677819
THANX!
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

762 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