Solved

Upper case in text box

Posted on 2010-09-14
8
726 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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 125 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

734 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