article

Parsing variables to a Sub

Email
Submitted on: 1/11/2019 4:01:58 PM
By: A_X_O 
Level: Beginner
User Rating: Unrated
Compatibility: VbScript (browser/client side)
Views: 1498
 
     A Basic and Simple demonstration of Passing Inputbox Variables to a SubRoutine


 
				'
'
'------------------------------------------------------------------------------	'
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	'
'		Demonstration: Windows 10, Parsing Variables			'
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	'
'										'
'	Purpose		:	Demonstrates VBScript Parsing Variables		'
'	-----------------------------------------------------------------------	'
'	Creation Date	: 	11/01/2019 [dd/mm/yyyy]				'
'	Version		:	1.0						'
'	Designer	:	Fabian						'
'										'
'##############################################################################	'
'			MODIFICATION HISTORY					'
'------------------------------------------------------------------------------	'
'	Version		:	1:0	11/01/2019	Create the Sample	'
'										'
'										'
'------------------------------------------------------------------------------	'		
'
Public Const StrQuestionNA = "What is your Nationality ?"					'Store the static strings in constants.
Public Const StrQuestionTL = "Pass Variables To Sub-Routine"					'	
'												'
Public Const StrQuestionFN = "What is your Name ?"						'
'												'
Public Const MsgRetNation = "Your Nationality is: "						'
Public Const MsgRetName = "Your Name is: "							'
Public Const ErrNation = "You chose not to answer the Nationality."				'
Public Const ErrName = "You chose not to answer the Name."					'
'
Dim strNationality										'Create a space in Memory for the Variables - Input Returns
Dim strName
'
	StrQuestionDF = "English"								'Set the default Nationality Option
'
	strNationality = InputBox(StrQuestionNA, StrQuestionTL, StrQuestionDF, 900, 800)	'Pose the Nationality Question to the user: Store reply in strNationality
'
	StrQuestionDF = VbNullString								'Remove the default Nationality text from the question
'
	strName = InputBox(StrQuestionFN, StrQuestionTL, StrQuestionDF, 900, 800)		'Pose Name Question to the user: Store reply in strName
'
Call DisplayInput(strNationality, strName)							'Parse or Pass / Send / Call DisplayInput with the 
'												'two variables: strNationality and strName
Public Sub DisplayInput(ByRef userNation, ByRef userName)
On Error Resume Next
'
If userNation = VbNullString Then								'Check if the Nationality variable has data in it.
'												'If not, enter some of our own data.
	userNation = ErrNation
'
End If
'
If userName = VbNullString Then									'Check if the Name variable has data in it.
'												'If not, enter some of our own data.
	userName = ErrName
'
End If
'
	MsgBox MsgRetNation & UCase(userNation) & VbCrLf & _
		MsgRetName & UCase(userName), _
		VbSystemModal + VbExClamation + VbOkCancel, StrQuestionTL			'Display the data back to the user.
'
	strNationality = VbNullString								'Empty the variables.
	strName = VbNullString
'
End Sub
'


Other 17 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.