[Gambas-user] why this code not working

T Lee Davidson t.lee.davidson at ...626...
Tue Jul 14 19:21:20 CEST 2015


On 07/14/2015 12:31 PM, tsukuba GIMP user wrote:
> Public Sub PictureBox1_MouseDown()
>
>    Dim dicer As Integer
>    Dim dbclick As Integer
>    dicer = Int(Rnd(1, 5))
>    dbclick = +1 <-------------------------------Problem code
>    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
__________





More information about the User mailing list