Link to home
Start Free TrialLog in
Avatar of 1r3o2n8
1r3o2n8Flag for United States of America

asked on

Upper case in text box



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?
Avatar of MWGainesJR
MWGainesJR
Flag of United States of America image


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

Avatar of 1r3o2n8

ASKER

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

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

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

Avatar of 1r3o2n8

ASKER

Your code did the job!  May I have an explanation of lines 5-8??
ASKER CERTIFIED SOLUTION
Avatar of MWGainesJR
MWGainesJR
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 1r3o2n8

ASKER

THANX!