Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Variabel and caption in userform

Define you variable in a general module at the top (insert=Module)

Public MyVar as String

Sub SetMyVar()
myVar = "ABCD"
End sub


then in the Userform Module

Private Sub Userform_Initialize()
me.Caption = MyVar
End Sub

--
Regards,
Tom Ogilvy


"Alvin Hansen" wrote in message
...
Hi

Can i use a variabel in my caption in my userform
sp the titel in my userform have the value of my variabel
and if i can how? And where shall i define my variabel?

Best regards

Alvin



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default Variabel and caption in userform

Thank you thank you all
It was a message box where the user shal write there name
and the name shall stand i the titel off my userform
and yes its working Wooooooooooow
Off course the best soloution would bee to take there user name
the have use to get on to the pc, but i don't believe i can do that

Many thanks

Alvin


"Tom Ogilvy" skrev:

Define you variable in a general module at the top (insert=Module)

Public MyVar as String

Sub SetMyVar()
myVar = "ABCD"
End sub


then in the Userform Module

Private Sub Userform_Initialize()
me.Caption = MyVar
End Sub

--
Regards,
Tom Ogilvy


"Alvin Hansen" wrote in message
...
Hi

Can i use a variabel in my caption in my userform
sp the titel in my userform have the value of my variabel
and if i can how? And where shall i define my variabel?

Best regards

Alvin




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Variabel and caption in userform

Alvin,

user name the have use to get on to the pc

You can access environment variables through the Environ() function:
msgbox Environ("username") '<-- returns user name
msgbox Environ("computername") '<-- returns computer name
so something like
Public uName as String

In your sub where you prompt the user:
uName = Environ("username")
if uname="" then 'if no user name
'Ask the user as you currenlty do
'or use computer name
'uname= ...
End If

In the sub where you assign the caption:
Userform1.Caption = uName

Regards,
Sebastien
"Alvin Hansen" wrote:

Thank you thank you all
It was a message box where the user shal write there name
and the name shall stand i the titel off my userform
and yes its working Wooooooooooow
Off course the best soloution would bee to take there user name
the have use to get on to the pc, but i don't believe i can do that

Many thanks

Alvin


"Tom Ogilvy" skrev:

Define you variable in a general module at the top (insert=Module)

Public MyVar as String

Sub SetMyVar()
myVar = "ABCD"
End sub


then in the Userform Module

Private Sub Userform_Initialize()
me.Caption = MyVar
End Sub

--
Regards,
Tom Ogilvy


"Alvin Hansen" wrote in message
...
Hi

Can i use a variabel in my caption in my userform
sp the titel in my userform have the value of my variabel
and if i can how? And where shall i define my variabel?

Best regards

Alvin




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default Variabel and caption in userform

Woow its works
I don't belive it so easy
thank you very much
I give a beer if you ever come to denmark

Best regards
Alvin


"sebastienm" skrev:

Alvin,

user name the have use to get on to the pc

You can access environment variables through the Environ() function:
msgbox Environ("username") '<-- returns user name
msgbox Environ("computername") '<-- returns computer name
so something like
Public uName as String

In your sub where you prompt the user:
uName = Environ("username")
if uname="" then 'if no user name
'Ask the user as you currenlty do
'or use computer name
'uname= ...
End If

In the sub where you assign the caption:
Userform1.Caption = uName

Regards,
Sebastien
"Alvin Hansen" wrote:

Thank you thank you all
It was a message box where the user shal write there name
and the name shall stand i the titel off my userform
and yes its working Wooooooooooow
Off course the best soloution would bee to take there user name
the have use to get on to the pc, but i don't believe i can do that

Many thanks

Alvin


"Tom Ogilvy" skrev:

Define you variable in a general module at the top (insert=Module)

Public MyVar as String

Sub SetMyVar()
myVar = "ABCD"
End sub


then in the Userform Module

Private Sub Userform_Initialize()
me.Caption = MyVar
End Sub

--
Regards,
Tom Ogilvy


"Alvin Hansen" wrote in message
...
Hi

Can i use a variabel in my caption in my userform
sp the titel in my userform have the value of my variabel
and if i can how? And where shall i define my variabel?

Best regards

Alvin




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Load caption box on userform open ExcelMonkey Excel Worksheet Functions 1 April 3rd 07 11:02 PM
Defining UserForm Caption from a Variable [email protected] Excel Worksheet Functions 1 January 3rd 07 02:30 PM
Visual basic Userform caption [email protected] Excel Programming 9 September 2nd 04 04:57 PM
Userform - Label Caption - How to update from a variable Alan Excel Programming 3 August 2nd 04 04:39 AM
UserForm Caption Soniya Excel Programming 2 October 4th 03 01:53 PM


All times are GMT +1. The time now is 06:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"