[Gambas-user] Value is not static

Gianluigi bagonergi at gmail.com
Wed Jun 16 17:17:05 CEST 2021


Il giorno mer 16 giu 2021 alle ore 16:56 KKing <kicking177 at gmail.com> ha
scritto:

> @BruceS Thankyou works
>
> @Gianluigi when I had
>     Dim class1 As New Class1
> it still didn't seem to work, but when I tried
>     Dim myClass1 as New Class1
> it was fine
>
> many thanks
> K
>

Here work fine.
Unfortunately someone confused your ideas and you thanked him ;-D

With Create static class:
-------------------------
' Gambas class file

Create Static

Public Value1 As Integer
Public Value2 As Integer

Public Function ProcessIt() As Boolean
  Value2 = Value1 * 2
  Return True
Catch
  Return False
End

' Gambas module file

Public Sub Main()

  Dim CalcValue As Integer

  class1.Value1 = 3
  If class1.ProcessIt() Then
    CalcValue = class1.Value2
    Print CalcValue
  Else
    Print "An error Occurred"
  Endif

End

---------------------------

with the instantiated class:
----------------------------------

' Gambas class file

Public Value1 As Integer
Public Value2 As Integer

Public Function ProcessIt() As Boolean
  Value2 = Value1 * 2
  Return True
Catch
  Return False
End

' Gambas module file

Public Sub Main()

  Dim class1 As New Class1
  Dim CalcValue As Integer

  class1.Value1 = 3
  If class1.ProcessIt() Then
    CalcValue = class1.Value2
    Print CalcValue
  Else
    Print "An error Occurred"
  Endif

End
-------------------------------

Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210616/25a0690a/attachment.htm>


More information about the User mailing list