[Gambas-user] Replace (Internal) Error Message

Bruce Steers bsteers4 at gmail.com
Tue May 23 18:09:59 CEST 2023


On Tue, 23 May 2023 at 12:47, Hans Lehmann <hans at gambas-buch.de> wrote:

> Hello.
>
> When I use the following procedure:
>
> Public Sub dcFlowername_Validate(Value As Variant)
>
>      If IsNull(Value) Then
>     '-- Message.Warning(Subst("&1<br>&2<b> &3 </b>&4", ("No flower name
> was entered!"), ("The data set is"), ("not"), ("saved!")))
>     '-- An *internal* error message is displayed!
>         Return
>      Endif
>
> End
>
> the same meaningless error message "Invalid value" is always displayed.
>
> Is there a way to replace this internal error message with a meaningful
> error message of my own?
>
> With kind regards
>
> Hans
>
> How are you getting the error message?
is it automatically printing or are you just reading Error.Text? because
your function does nothing to reset or produce an error so the error message
will be from what ever Try instruction last failed.

if so use Error.Clear to clear the last error message before your function
or do not read Error.Text if you have not used a method to clear/set it.
And i assume you call
dcFlowername_Validate(Null)
not
dcFlowername_Validate()

the second type with no args needs...
Public Sub dcFlowername_Validate(Optional Value As Variant)

BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230523/fbc5acf6/attachment.htm>


More information about the User mailing list