[Gambas-user] try if error
Adam Ant
adamnt42 at gmail.com
Wed Jun 20 11:26:54 CEST 2018
You cannot use Try If because If will always return a value.
The above posters are correct.
Dim Trydate as Date
Try Trydate=(gibberish)
If Error then
handle it
else
do whatever
Endif
On Wed, Jun 20, 2018 at 5:45 PM, Mike Crean via User <
user at lists.gambas-basic.org> wrote:
> If it were available in Gambas I would think it would be something like
>
> Try
> Date(2018,13,1)
> If Error Then
> Resume Next
>
> Tegards
> Mike
>
>
>
> On Wednesday, 20 June 2018, 4:10:05 pm AWST, Mike Crean via User <
> user at lists.gambas-basic.org> wrote:
>
>
> In VB.Net it is
>
> Try
> Date(2018,13,1)
> If Error Resume Next
>
> This will tell it to resume at the next error without taking any other
> action.
>
> Regards
> Mike
>
> On Wednesday, 20 June 2018, 3:48:06 pm AWST, Gianluigi <
> bagonergi at gmail.com> wrote:
>
>
> I can not understand what you want to get.
> Now also .net uses Try, Catch and Finally.
> If you want to continue after the error set just try:
> Try something
> Try something else
> if you want to stop set:
> Try something
> if error then return
> Otherwise read here:
> http://gambaswiki.org/wiki/comp/gb/error
>
> In particular:
> Public Sub Main()
>
> Dim x As Date
>
> Try x = Date(2018, 13, 1)
> If Error Then
> Print "Month max 12"
> Else
> Print "Exit"
> Return
> Endif
>
> End
>
> Regards
> Gianluigi
>
> 2018-06-20 0:18 GMT+02:00 Mayost Sharon <sharon at 455.co.il>:
>
> OK
>
> BUT IS:
>
> Try If Date(2018,13,1) then stop
>
> ---------- Original Message -----------
> From: Gianluigi <bagonergi at gmail.com>
> To: Gambas Mailing List <user at lists.gambas-basic.org>
> Sent: Tue, 19 Jun 2018 23:52:14 +0200
> Subject: Re: [Gambas-user] try if error
>
> > Public Sub Main()
> >
> > Dim i As Integer
> >
> > Try i = "Mickey Mouse"
> > Try i = "Pluto"
> > Try i = "1"
> > Print i
> >
> > End
> >
> > Regards
> > Gianluigi
> >
> > 2018-06-19 23:37 GMT+02:00 Mayost Sharon <sharon at 455.co.il>:
> >
> > > Sorry
> > > I meant in Visual Basic
> > > To skip to the next line
> > > There is the command
> > >
> > > On Error Resume Next
> > >
> > > In GAMBAS there is no possibility
> > >
> > >
> > > ---------- Original Message -----------
> > > From: Gianluigi <bagonergi at gmail.com>
> > > To: Gambas Mailing List <user at lists.gambas-basic.org>
> > > Sent: Tue, 19 Jun 2018 23:05:47 +0200
> > > Subject: Re: [Gambas-user] try if error
> > >
> > > > For those who want to know what 'Goto 0' means in Vb:
> > > > https://stackoverflow.com/ questions/9983464/why-would-
> <https://stackoverflow.com/questions/9983464/why-would->
> > > you-ever-use-on-error-
> > > > goto-0
> > > >
> > > > Regards
> > > > Gianluigi
> > > >
> > > > 2018-06-19 22:54 GMT+02:00 Mayost Sharon <sharon at 455.co.il>:
> > > >
> > > > > OK
> > > > >
> > > > > Many thanks
> > > > >
> > > > > ---------- Original Message -----------
> > > > > From: Jussi Lahtinen <jussi.lahtinen at gmail.com>
> > > > > To: Gambas Mailing List <user at lists.gambas-basic.org>
> > > > > Sent: Tue, 19 Jun 2018 23:49:33 +0300
> > > > > Subject: Re: [Gambas-user] try if error
> > > > >
> > > > > > Dim hDate As Date
> > > > > >
> > > > > > Try hDate =Date(2018, 13, 1)
> > > > > >
> > > > > > If Error Then
> > > > > > Print "Date Error"
> > > > > > Endif
> > > > > >
> > > > > > If hDate = something Then
> > > > > >
> > > > > > ...
> > > > > >
> > > > > > Jussi
> > > > > >
> > > > > > On Tue, Jun 19, 2018 at 11:46 PM, Mayost Sharon <
> sharon at 455.co.il>
> > > > > wrote:
> > > > > >
> > > > > > > This is not a good option
> > > > > > > Because it will send a print every time
> > > > > > > If the date is correct
> > > > > > >
> > > > > > > ---------- Original Message -----------
> > > > > > > From: Yahoo via User <user at lists.gambas-basic.org>
> > > > > > > To: Gambas Mailing List <user at lists.gambas-basic.org>, Jussi
> > > Lahtinen
> > > > > > > <jussi.lahtinen at gmail.com>
> > > > > > > Cc: Yahoo <olivier.cruilles at yahoo.fr>
> > > > > > > Sent: Tue, 19 Jun 2018 16:35:33 -0400
> > > > > > > Subject: Re: [Gambas-user] try if error
> > > > > > >
> > > > > > > > Better this form:
> > > > > > > >
> > > > > > > > Try Print Date(2018, 13, 1)
> > > > > > > > IF Error Then
> > > > > > > > Print "Wrong Date format"
> > > > > > > > else
> > > > > > > > ‘ Do something whit your date….
> > > > > > > > End If
> > > > > > > >
> > > > > > > > Cordialement,
> > > > > > > > —
> > > > > > > > Olivier Cruilles
> > > > > > > > Email: olivier.cruilles at yahoo.fr
> > > > > > > >
> > > > > > > > Le June 19, 2018 à 16:30:03, Jussi Lahtinen (
> > > > > jussi.lahtinen at gmail.com)
> > > > > > > a écrit:
> > > > > > > >
> > > > > > > > Oh, maybe you want to use Catch structure...
> > > > > > > > http://gambaswiki.org/wiki/ lang/catch
> <http://gambaswiki.org/wiki/lang/catch>
> > > > > > > >
> > > > > > > > Jussi
> > > > > > > >
> > > > > > > > On Tue, Jun 19, 2018 at 11:27 PM, Jussi Lahtinen <
> > > > > > > jussi.lahtinen at gmail.com> wrote:
> > > > > > > > I don't understand the problem.
> > > > > > > >
> > > > > > > > If Error Then Goto ErrorHandling
> > > > > > > >
> > > > > > > > ...
> > > > > > > >
> > > > > > > > ErrorHandling:
> > > > > > > > Print "Here is my error handling"
> > > > > > > >
> > > > > > > > Jussi
> > > > > > > >
> > > > > > > > On Tue, Jun 19, 2018 at 11:22 PM, Mayost Sharon <
> > > sharon at 455.co.il>
> > > > > > > wrote:
> > > > > > > > In Visual Basic
> > > > > > > > there is
> > > > > > > > on error goto 0
> > > > > > > >
> > > > > > > > ---------- Original Message -----------
> > > > > > > > From: PICCORO McKAY Lenz <mckaygerhard at gmail.com>
> > > > > > > > To: Gambas Mailing List <user at lists.gambas-basic.org>
> > > > > > > > Sent: Tue, 19 Jun 2018 16:18:06 -0400
> > > > > > > > Subject: Re: [Gambas-user] try if error
> > > > > > > >
> > > > > > > > > 2018-06-19 16:06 GMT-04:00 Mayost Sharon <sharon at 455.co.il
> >:
> > > > > > > > >
> > > > > > > > > > Hello
> > > > > > > > > >
> > > > > > > > > > How do I proceed to the next line
> > > > > > > > > > If there is an error
> > > > > > > > > >
> > > > > > > > > for cases when it's error format or error of invalid date
> just:
> > > > > > > > >
> > > > > > > > > If Date(2018, 13, 1) Then
> > > > > > > > >
> > > > > > > > > for others error might be a good question unless compared
> using
> > > > > Comp()
> > > > > > > as
> > > > > > > > > strings!
> > > > > > > > >
> > > > > > > > > i dont know what other type of errors can be produced here!
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > For example, if the date is not correct
> > > > > > > > > >
> > > > > > > > > > ' Gambas module file
> > > > > > > > > >
> > > > > > > > > > Public Sub Main()
> > > > > > > > > >
> > > > > > > > > > Try Print Date(2018, 13, 1)
> > > > > > > > > >
> > > > > > > > > > If Date(2018, 13, 1) Then
> > > > > > > > > >
> > > > > > > > > > Endif
> > > > > > > > > >
> > > > > > > > > > End
> > > > > > > > > >
> > > > > > > > > > Thank you
> > > > > > > > > >
> > > > > > > > > > ----[ Gambas mailing-list is hosted by
> > > > > https://www.hostsharing.net
> > > > > > > ]----
> > > > > > > > > >
> > > > > > > > ------- End of Original Message -------
> > > > > > > >
> > > > > > > > ----[ Gambas mailing-list is hosted by
> > > https://www.hostsharing.net
> > > > > ]----
> > > > > > > >
> > > > > > > > ----[ Gambas mailing-list is hosted by
> > > https://www.hostsharing.net
> > > > > ]----
> > > > > > > ------- End of Original Message -------
> > > > > > >
> > > > > > >
> > > > > > > ----[ Gambas mailing-list is hosted by
> https://www.hostsharing.net
> > > > > ]----
> > > > > > >
> > > > > ------- End of Original Message -------
> > > > >
> > > > >
> > > > > ----[ Gambas mailing-list is hosted by https://www.hostsharing.net
> > > ]----
> > > > >
> > > ------- End of Original Message -------
> > >
> > >
> > > ----[ Gambas mailing-list is hosted by https://www.hostsharing.net
> ]----
> > >
> ------- End of Original Message -------
>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20180620/9dce57ec/attachment-0001.html>
More information about the User
mailing list