I am using a global function and calling it when the task is ran. I can set one of the textboxes to log as it is the overall applications logging textbox, however I have another textbox on the tab the users will be interfacing with, to show their progress, errors, etc..
The issue I am having is passing the textbox into the function as a parameter.
The following is my basic function, where I tried to recreate the $tbx_whatever name of the textbox, however I get an error with this.
"ERROR: Method invocation failed because [System.String] does not contain a method named 'appendtext'."
Code: Select all
function write-Applog
{
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$Message,
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]$appTab,
[Parameter()]
$localLog
)
$LogMessage = [pscustomobject]@{
Time = (Get-Date -f g)
Message = $Message
AppTab = $appTab
}
$rtb_Logs_Output.appendtext("[$($LogMessage.Time)]::[$appTab]::$Message`n")
if ($localLog)
{
$localtbx = "`${0}" -f $localLog
$localtbx.appendText("[$appTab]:$Message`n")
}
}