|
-
Apr 24th, 2010, 02:30 AM
#1
Thread Starter
Hyperactive Member
how to share string in all form(s), via module?
I have problem:
why not work ?
please!
Code:
'Form1
Private Sub Command1_Click()
MsgBox a
MsgBox b
End Sub
'Module1
Public a As String
Public b as string
a = CStr(Form1.Text1.Text)
b = App.Path
Last edited by rpool; Apr 24th, 2010 at 02:49 AM.
-
Apr 24th, 2010, 02:45 AM
#2
Addicted Member
Re: simple string in module
 Originally Posted by rpool
I have problem:
why not work ?
please!
Code:
'Form1
Private Sub Command1_Click()
MsgBox a
MsgBox b
End Sub
'Module1
Public a As String
Public b as string
a = CStr(Form1.Text1.Text)
b = App.Path
Try to put this code on Form Load
-
Apr 24th, 2010, 02:47 AM
#3
Thread Starter
Hyperactive Member
Re: simple string in module
yes, put to Form_Load is work.
But how to share that "a" "b" string in all form(s).
-
Apr 24th, 2010, 02:51 AM
#4
Addicted Member
Re: simple string in module
 Originally Posted by rpool
yes, put to Form_Load is work.
But how to share that "a" "b" string in all form(s).
You can do this :
Module 1
Code:
Public a As String
Public B As String
Public Sub Outside()
a = CStr(Form1.Text1.Text)
B = App.Path
End Sub
On Button CLick, set :
Code:
Outside
Msgbox a
Msgbox b
-
Apr 24th, 2010, 02:57 AM
#5
Thread Starter
Hyperactive Member
Re: how to share string in all form(s), via module?
how about this styles: ? same
Code:
'form1
Private Sub Command1_Click()
MsgBox astr
End Sub
'module1
Public Function astr() As String
astr = "module1 string"
End Function
-
Apr 24th, 2010, 04:04 AM
#6
Re: how to share string in all form(s), via module?
You can use sub main() also.
Code in a module:
Code:
'~~~ You have to set the Startup object (Project menu --> Project Properties --> Startup Object) to "Sub Main"
Option Explicit
Public a As String
Public b As String
Sub main() '~~~ Execution of the program starts here
'~~~ Initialize values
a = "Hello"
b = App.Path
Form1.Show '~~~ Display Form1
End Sub
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|