[Gambas-user] why this code not working
Fabien Bodard
gambas.fr at ...626...
Tue Jul 14 20:04:24 CEST 2015
You must define dbclick as a private variable. In your case the variable
is local and is initialized and destroyed in the procedure
Le 14 juil. 2015 19:31, "tsukuba GIMP user" <tsukubagraduates at ...3482...>
a écrit :
> As you said I changed into “dbclick + = 1”or “inc dbclick”
> but this time i add "print dbclick"(test only) then... print alwasy's 1
> when i click picturebox
>
> > Public Sub PictureBox1_MouseDown()
> >
> > Dim dicer As Integer
> > Dim dbclick As Integer
> > dicer = Int(Rnd(1, 5))
> > dbclick = +1 <-------------------------------Problem code
> > print dbclick <---------------(TEST ONLY)
> > If dbclick = 8 Then <------- i click 8 time but it's don't run this
> code just like my program forget this code
> > Form3.Text = ("xxxxx")
> > Form3.TextBox1.text = ("xxxxxx!!!!!!!")
> > Form3.Show
> > Else
> > Goto just_keep_moveing
> > Endif
> > just_keep_moveing:
> > If dicer = 1 Then
> > Form3.Text = ("xxxx")
> > Form3.TextBox1.Text = ("xxxxxxx~")
> > Form3.Show
> > Else If dicer = 2 Then
> > Form3.Text = ("xxxx")
> > Form3.TextBox1.text = ("xxxxx!xxxx!")
> > Form3.Show
> > Else If dicer = 3 Then
> > Form3.Text = ("xxxx")
> > Form3.TextBox1.text = ("xxxxxxx?")
> > Form3.Show
> > Else If dicer = 4 Then
> > Form3.Text = ("xxxx")
> > Form3.TextBox1.text = ("xxxx!")
> > Form3.Show
> > Endif
> > End
>
> There are a couple of reasons why the code doesn't work as I think you are
> expecting.
>
> 1. Because the syntax, "dbclick = +1", assigns positive 1 to dbclick each
> time it is executed. The syntax should be "dbclick +=
> 1", or "Inc dbclick".
>
> 2. You have declared dbclick within the function and it therefore gets,
> essentially, reset to 0 on each call of the function.
>
>
> Lee
> __________
>
>
>
> ------------------------------------------------------------------------------
> Don't Limit Your Business. Reach for the Cloud.
> GigeNET's Cloud Solutions provide you with the tools and support that
> you need to offload your IT needs and focus on growing your business.
> Configured For All Businesses. Start Your Cloud Today.
> https://www.gigenetcloud.com/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
>
> ------------------------------------------------------------------------------
> Don't Limit Your Business. Reach for the Cloud.
> GigeNET's Cloud Solutions provide you with the tools and support that
> you need to offload your IT needs and focus on growing your business.
> Configured For All Businesses. Start Your Cloud Today.
> https://www.gigenetcloud.com/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list