What is the function of a Function?

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 8 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
vagulus
Posts: 9
Last visit: Mon Feb 29, 2016 7:00 pm

What is the function of a Function?

Post by vagulus »

Product, version and build: PS 2015
32 or 64 bit version of product: 64
Operating system: W7
32 or 64 bit OS: 64

I am trying to figure out whether or not a Function returns the value it generates by its own name. I have this code:

Function readInput(CellIndex)
' debug
WScript.Echo "In readInput"

readInput = InputBox("Enter Coefficient " & CellIndex, vbOKOnly+vbQuestion, "Coefficient Entry")

' debug
WScript.Echo "Entered datum was " & readInput <------ This code works fine <------
End Function ' readInput

' ----------------------------------------------------------------------------

Sub validateTheDatum(DataArray, RunTheProgram, CellIndex, ValidSignal)
' Selection Sub to ensure only numeric data is returned

' debug
WScript.Echo "In validateTheDatum"
Dim val
val = readInput CellIndex <------ Debug expects 'End of Statement' here <------
wscript.Echo val

' After debugging, working code will go here

' debug
ValidSignal = False
WScript.Echo "validateTheDatum just changed ValidSignal to" & ValidSignal

End Sub ' validateTheDatum


I am expecting the variable 'val' to get take the value the User enters in the InputBox. Debug says there is something wrong with the statement.

What have I misinterpreted?
User avatar
Alexander Riedel
Posts: 8575
Last visit: Sat Nov 02, 2024 12:15 pm
Answers: 23
Been upvoted: 42 times

Re: What is the function of a Function?

Post by Alexander Riedel »

Topic moved to correct forum by moderator
Alexander Riedel
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: What is the function of a Function?

Post by jvierra »

None of your functions return a value. They all return Null.
This topic is 8 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked