Just Learning VB, Question? 
Author Message
 Just Learning VB, Question?

Hello,

I just started to try to teach myself VB 5.0 using Que's Book VB Night
School.  I am doing ok but I have a question about VB or is it an
error in the book.

Chapter 13 ask you to complete the following to finish the homework.

Write a module that contains two subroutine procedures.  The first
procedure asks for a name and the second prints the mane.  Don't use
any module-level or public variables in the module.

I think this is not posible.  Sub procedures don't return any value so
how do I get the name out of the first porcedure and into the second
to print it.  I think they have to be functions not subroutine
procedures??

Any help would be appreciated.

Dave A.

***********************************
Remove nospam to e-mail me.



Fri, 02 Feb 2001 03:00:00 GMT  
 Just Learning VB, Question?
I take it you'll need something to enter the name on for the first sub
(a form?), you could then refernce the control with the name in for
the print sub.

Maybe???

NE


Quote:

>Hello,

>I just started to try to teach myself VB 5.0 using Que's Book VB Night
>School.  I am doing ok but I have a question about VB or is it an
>error in the book.

>Chapter 13 ask you to complete the following to finish the homework.

>Write a module that contains two subroutine procedures.  The first
>procedure asks for a name and the second prints the mane.  Don't use
>any module-level or public variables in the module.

>I think this is not posible.  Sub procedures don't return any value so
>how do I get the name out of the first porcedure and into the second
>to print it.  I think they have to be functions not subroutine
>procedures??

>Any help would be appreciated.

>Dave A.

>***********************************
>Remove nospam to e-mail me.



Fri, 02 Feb 2001 03:00:00 GMT  
 Just Learning VB, Question?
You can do it with subroutines only, but it is poor programming style.  By
default, arguments passed to a Sub or Function are passed by reference,
meaning that changes made to the parameter variable in the subroutine will be
reflected in the argument in the calling statement.  The trick is to pass the
first Sub a string variable and let the Sub modify it.

Calling statements:

        Dim sInput as String
        Call UserInput(sInput)
        Call UserOutput(sInput)

Private Sub UserInput(sUserInput as String)
        sUserInput = InputBox("Enter a string, please:")
End Sub

Private Sub UserOutput(sUserOutput as String)
        Printer.Print sUserOutput
End Sub

Lee Weiner
weiner AT fuse DOT net


Quote:

>Hello,

>I just started to try to teach myself VB 5.0 using Que's Book VB Night
>School.  I am doing ok but I have a question about VB or is it an
>error in the book.

>Chapter 13 ask you to complete the following to finish the homework.

>Write a module that contains two subroutine procedures.  The first
>procedure asks for a name and the second prints the mane.  Don't use
>any module-level or public variables in the module.

>I think this is not posible.  Sub procedures don't return any value so
>how do I get the name out of the first porcedure and into the second
>to print it.  I think they have to be functions not subroutine
>procedures??

>Any help would be appreciated.

>Dave A.

>***********************************
>Remove nospam to e-mail me.



Fri, 02 Feb 2001 03:00:00 GMT  
 Just Learning VB, Question?
sub firstsub()
        dim zName as string
        ' get name from user using inputbox or whatever here
        secondsub zName
end sub

sub secondsub(zN as string)
        ' print zN here
end sub

-- or did I not understand you?



Quote:
> Hello,

> I just started to try to teach myself VB 5.0 using Que's Book VB Night
> School.  I am doing ok but I have a question about VB or is it an
> error in the book.

> Chapter 13 ask you to complete the following to finish the homework.

> Write a module that contains two subroutine procedures.  The first
> procedure asks for a name and the second prints the mane.  Don't use
> any module-level or public variables in the module.

<snip>


Sat, 03 Feb 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Help - New VB person has a question about learning VB.

2. help: text justed in reports access

3. Just learning vb.net, question about strings

4. Question about VB Learning Ed.

5. Question for VB learning edition

6. Newbie Question - Can VB 5 (Learning) Create An Access Database On the Fly

7. Learn VB7 or learn Java ?

8. Difference between VB learning and VB Pro ???

9. Learning VB and VB.Net

10. VB enterprise becomes VB learning ???

11. Learning Visual Basic Learning Edition Deluxe/Professional Edition

12. VB 5.0 Professional Ed. suddenly becomes VB 5.0 Learning Ed.

 

 
Powered by phpBB® Forum Software