Solved

Upper case in text box

Posted on 2010-09-14
8
728 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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 …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

724 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