Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FUNCTION IN VB6 THAT DONT WORK IN EXCEL 1

Status
Not open for further replies.

JCooL

Programmer
Oct 21, 2001
89
US
Hi there,
Code:
Public Sub Capital(str As TextBox)
  str = UCase(str.Text)
  str.SelLength = Len(str.Text)
End Sub

Private Sub Text1_Change()
  Capital Text1
End Sub
I made this function in VB6 when i trying to make the same in Ecxel with a Texbox1 i recive this message "Type MisMatch", in Excel the Code look like this...

Code:
Public Sub Capital(str As TextBox)
     str = UCase(str.Text)
     str.SelLength = Len(str.Text)
End Sub

Private Sub TextBox1_Change()
   Captial TextBox1   <<Here the error
End Sub
Thanks By First

 
If you have copied and pasted from your code then replace:
Captial with Capital

But I doubt it would be that easy.
 
Thanx...

Now yes.

Excel Code
Code:
Public Sub Capital(str As TextBox)
     str = UCase(str.Text)
     str.SelLength = Len(str.Text)
End Sub

Private Sub TextBox1_Change()
   Capital TextBox1   <<Here the error
End Sub
 
JCool,

Change your Sub declaration as follows:

Code:
Public Sub Capital(str As MSForms.TextBox)
     str = UCase(str.Text)
     str.SelLength = Len(str.Text)
End Sub


Regards,
Mike
 
How can str = Textbox AND Textbox.Text - that's a type mismatch if I ever saw one (esp as str is defined as textbox NOT string) Rgds
~Geoff~
 
Hi,

All right rmikesmith, thats really work!

Thanx to all there...

'til next
 
Hey JCool - if Mike has helped you, you may wanna give him a star. You can do this by clicking on the &quot;Mark This post as a helpful/expert post&quot;. This is the Tek-Tips method for saying thanx but just as importantly, flags posts for which good / helpful answers have been given. This, in turn, makes searching the archives for previous answers to similar questions much easier Rgds
~Geoff~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top