forms in vba

forms in vba

Anonymous
Not applicable
840 Views
9 Replies
Message 1 of 10

forms in vba

Anonymous
Not applicable
I create an vba program that do some action calls a user form, I put data
in it. And the program should finnishe.

But my program stops after excecuting the form.


Next question.

How can I get variabels (DIM) to the form and back.

Thanks a lot
0 Likes
841 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable
1. Difficult to help you without seeing what you are doing.
How are you calling the form?
How are you leaving the form?
Show some code.

2. Add a PUBLIC variable in the module section (before any SUB's or
FUNCTION's) of the THISDRAWING code module (e.g. Public strSomeText As
String), then refer to it in the form code via the THISDRAWING object (e.g.
ThisDrawing.strSomeText).
--
John Goodfellow
irtfnm
use john at goodfellowassoc dot com


"gvanaco" wrote in message
news:5F6E8DC3EAB881994EAD6F370E7A27AD@in.WebX.maYIadrTaRb...
> I create an vba program that do some action calls a user form, I put data
> in it. And the program should finnishe.
>
> But my program stops after excecuting the form.
>
>
> Next question.
>
> How can I get variabels (DIM) to the form and back.
>
> Thanks a lot
0 Likes
Message 3 of 10

Anonymous
Not applicable
The program is a connection to a excel tabel.

I would selecting one sheet from the excel file.

It works for displaying the sheetnames but I do not nowing how I should
selecting.





"John Goodfellow" wrote in
news:A31531C764B4BE301AB7606C0E963809@in.WebX.maYIadrTaRb:

> 1. Difficult to help you without seeing what you are doing.
> How are you calling the form?
> How are you leaving the form?
> Show some code.
>
> 2. Add a PUBLIC variable in the module section (before any SUB's or
> FUNCTION's) of the THISDRAWING code module (e.g. Public strSomeText As
> String), then refer to it in the form code via the THISDRAWING object
> (e.g. ThisDrawing.strSomeText).
> --
> John Goodfellow
> irtfnm
> use john at goodfellowassoc dot com
>
>
> "gvanaco" wrote in message
> news:5F6E8DC3EAB881994EAD6F370E7A27AD@in.WebX.maYIadrTaRb...
>> I create an vba program that do some action calls a user form, I put
>> data in it. And the program should finnishe.
>>
>> But my program stops after excecuting the form.
>>
>>
>> Next question.
>>
>> How can I get variabels (DIM) to the form and back.
>>
>> Thanks a lot
>
>
0 Likes
Message 4 of 10

Anonymous
Not applicable
I try a second time
0 Likes
Message 5 of 10

Anonymous
Not applicable
In your module, declare a global variable (example: sSheetName). In the
button click event, transfer the list box value to that variable:

in module:
public sSheetName as string

in form:
Private Sub CommandButton1_Click()
sSheetName = ListBox1.Value
Unload Me
'now call some other routine, or run other code here
End Sub

--
Kevin


"gvanaco" wrote in message
news:9B5C3EF2F361BAE85F7FB4143EAC83A2@in.WebX.maYIadrTaRb...
> The program is a connection to a excel tabel.
>
> I would selecting one sheet from the excel file.
>
> It works for displaying the sheetnames but I do not nowing how I should
> selecting.
>
>
>
>
>
> "John Goodfellow" wrote in
> news:A31531C764B4BE301AB7606C0E963809@in.WebX.maYIadrTaRb:
>
> > 1. Difficult to help you without seeing what you are doing.
> > How are you calling the form?
> > How are you leaving the form?
> > Show some code.
> >
> > 2. Add a PUBLIC variable in the module section (before any SUB's or
> > FUNCTION's) of the THISDRAWING code module (e.g. Public strSomeText As
> > String), then refer to it in the form code via the THISDRAWING object
> > (e.g. ThisDrawing.strSomeText).
> > --
> > John Goodfellow
> > irtfnm
> > use john at goodfellowassoc dot com
> >
> >
> > "gvanaco" wrote in message
> > news:5F6E8DC3EAB881994EAD6F370E7A27AD@in.WebX.maYIadrTaRb...
> >> I create an vba program that do some action calls a user form, I put
> >> data in it. And the program should finnishe.
> >>
> >> But my program stops after excecuting the form.
> >>
> >>
> >> Next question.
> >>
> >> How can I get variabels (DIM) to the form and back.
> >>
> >> Thanks a lot
> >
> >
>
0 Likes
Message 6 of 10

Anonymous
Not applicable
and if the form disapere, my initial program stays running?


thanks for the help

"Kevin Terry" wrote in
news:607D83D4FDE2C6C9EFAE30BF533D0201@in.WebX.maYIadrTaRb:

> In your module, declare a global variable (example: sSheetName). In
the
> button click event, transfer the list box value to that variable:
>
> in module:
> public sSheetName as string
>
> in form:
> Private Sub CommandButton1_Click()
> sSheetName = ListBox1.Value
> Unload Me
> 'now call some other routine, or run other code here
> End Sub
>
> --
> Kevin
>
>
> "gvanaco" wrote in message
> news:9B5C3EF2F361BAE85F7FB4143EAC83A2@in.WebX.maYIadrTaRb...
>> The program is a connection to a excel tabel.
>>
>> I would selecting one sheet from the excel file.
>>
>> It works for displaying the sheetnames but I do not nowing how I
should
>> selecting.
>>
>>
>>
>>
>>
>> "John Goodfellow" wrote in
>> news:A31531C764B4BE301AB7606C0E963809@in.WebX.maYIadrTaRb:
>>
>> > 1. Difficult to help you without seeing what you are doing.
>> > How are you calling the form?
>> > How are you leaving the form?
>> > Show some code.
>> >
>> > 2. Add a PUBLIC variable in the module section (before any SUB's or
>> > FUNCTION's) of the THISDRAWING code module (e.g. Public strSomeText
As
>> > String), then refer to it in the form code via the THISDRAWING
object
>> > (e.g. ThisDrawing.strSomeText).
>> > --
>> > John Goodfellow
>> > irtfnm
>> > use john at goodfellowassoc dot com
>> >
>> >
>> > "gvanaco" wrote in message
>> > news:5F6E8DC3EAB881994EAD6F370E7A27AD@in.WebX.maYIadrTaRb...
>> >> I create an vba program that do some action calls a user form, I
put
>> >> data in it. And the program should finnishe.
>> >>
>> >> But my program stops after excecuting the form.
>> >>
>> >>
>> >> Next question.
>> >>
>> >> How can I get variabels (DIM) to the form and back.
>> >>
>> >> Thanks a lot
>> >
>> >
>>
>
>
>
0 Likes
Message 7 of 10

Anonymous
Not applicable
That depends on what you want the program to do. You can run code without a
form on screen, and also can continue to run after the form is dismissed.

In a code module:
Public Sub test1()

UserForm1.Show

'now any code in the form's initialize event will run
'press button on form to dismiss form,
'code in button click event runs - make sure there's a Hide statement
for the form in this event

Unload UserForm1

'now you can run some code here, depending on user's input on form

End Sub

--
Kevin


"gvanaco" wrote in message
news:3685FC535499E4DB77DB17AB1EC6B9D9@in.WebX.maYIadrTaRb...
> and if the form disapere, my initial program stays running?
>
>
> thanks for the help
>
> "Kevin Terry" wrote in
> news:607D83D4FDE2C6C9EFAE30BF533D0201@in.WebX.maYIadrTaRb:
>
> > In your module, declare a global variable (example: sSheetName). In
> the
> > button click event, transfer the list box value to that variable:
> >
> > in module:
> > public sSheetName as string
> >
> > in form:
> > Private Sub CommandButton1_Click()
> > sSheetName = ListBox1.Value
> > Unload Me
> > 'now call some other routine, or run other code here
> > End Sub
> >
> > --
> > Kevin
> >
> >
> > "gvanaco" wrote in message
> > news:9B5C3EF2F361BAE85F7FB4143EAC83A2@in.WebX.maYIadrTaRb...
> >> The program is a connection to a excel tabel.
> >>
> >> I would selecting one sheet from the excel file.
> >>
> >> It works for displaying the sheetnames but I do not nowing how I
> should
> >> selecting.
> >>
> >>
> >>
> >>
> >>
> >> "John Goodfellow" wrote in
> >> news:A31531C764B4BE301AB7606C0E963809@in.WebX.maYIadrTaRb:
> >>
> >> > 1. Difficult to help you without seeing what you are doing.
> >> > How are you calling the form?
> >> > How are you leaving the form?
> >> > Show some code.
> >> >
> >> > 2. Add a PUBLIC variable in the module section (before any SUB's or
> >> > FUNCTION's) of the THISDRAWING code module (e.g. Public strSomeText
> As
> >> > String), then refer to it in the form code via the THISDRAWING
> object
> >> > (e.g. ThisDrawing.strSomeText).
> >> > --
> >> > John Goodfellow
> >> > irtfnm
> >> > use john at goodfellowassoc dot com
> >> >
> >> >
> >> > "gvanaco" wrote in message
> >> > news:5F6E8DC3EAB881994EAD6F370E7A27AD@in.WebX.maYIadrTaRb...
> >> >> I create an vba program that do some action calls a user form, I
> put
> >> >> data in it. And the program should finnishe.
> >> >>
> >> >> But my program stops after excecuting the form.
> >> >>
> >> >>
> >> >> Next question.
> >> >>
> >> >> How can I get variabels (DIM) to the form and back.
> >> >>
> >> >> Thanks a lot
> >> >
> >> >
> >>
> >
> >
> >
>
0 Likes
Message 8 of 10

Anonymous
Not applicable
Do you have a little and easy working axample of it where:


in a module the program is working

after an proces there rise a form, tath make a choise

the form dissepear

the program continu.



Maby you have something, so I can see how it's work,


Thanks a lot



"Kevin Terry" wrote in
news:8ACEBBEA6077C3AA228B2A10FB51521A@in.WebX.maYIadrTaRb:

> That depends on what you want the program to do. You can run code
> without a form on screen, and also can continue to run after the form
> is dismissed.
>
> In a code module:
> Public Sub test1()
>
> UserForm1.Show
>
> 'now any code in the form's initialize event will run
> 'press button on form to dismiss form,
> 'code in button click event runs - make sure there's a Hide
> statement
> for the form in this event
>
> Unload UserForm1
>
> 'now you can run some code here, depending on user's input on form
>
> End Sub
>
> --
> Kevin
0 Likes
Message 9 of 10

Anonymous
Not applicable
Look in the "sample" folder in the ACADCAD directory, there are a few there
with readme files explaining what they do and how they do it.
Murph

"gvanaco" wrote in message
news:3105FEA03D7B9C63E3EE221103276342@in.WebX.maYIadrTaRb...
> Do you have a little and easy working axample of it where:
>
>
> in a module the program is working
>
> after an proces there rise a form, tath make a choise
>
> the form dissepear
>
> the program continu.
>
>
>
> Maby you have something, so I can see how it's work,
>
>
> Thanks a lot
>
>
>
> "Kevin Terry" wrote in
> news:8ACEBBEA6077C3AA228B2A10FB51521A@in.WebX.maYIadrTaRb:
>
> > That depends on what you want the program to do. You can run code
> > without a form on screen, and also can continue to run after the form
> > is dismissed.
> >
> > In a code module:
> > Public Sub test1()
> >
> > UserForm1.Show
> >
> > 'now any code in the form's initialize event will run
> > 'press button on form to dismiss form,
> > 'code in button click event runs - make sure there's a Hide
> > statement
> > for the form in this event
> >
> > Unload UserForm1
> >
> > 'now you can run some code here, depending on user's input on form
> >
> > End Sub
> >
> > --
> > Kevin
0 Likes
Message 10 of 10

Anonymous
Not applicable
gvanaco wrote in
news:5F6E8DC3EAB881994EAD6F370E7A27AD@in.WebX.maYIadrTaRb:

> I create an vba program that do some action calls a user form, I put
> data in it. And the program should finnishe.
>
> But my program stops after excecuting the form.
>
>
> Next question.
>
> How can I get variabels (DIM) to the form and back.
>
> Thanks a lot

for my second question I have found the error.

A variable I have to declarate it in the option explicit.

Then stay's my variable working in different sub's

thanks
0 Likes