activate a click onto a picture button

  • Thread starter Thread starter Elton
  • Start date Start date
E

Elton

Dear All,

I am new to vb , please help.

I have a picture , and a picture_click( ) function. What I want to do is to
have a simulate a click event onto the picture in a loop. However, when I
write:


for i = 1 to 10
picture_click()
....


it gives me an error messge, said that I missed some parameter in the click
function call.
I searched through google, and found some people suggest to put "sender" and
"e" in the () as parameter.

but then another error message generated, sender and e is not definted.

Can you help? thanks.
 
Elton,

You are not the first who asked this, but why not call just the event that
you want to do with the click than to perform the click.

MyEvent(nothing,nothing) is mostly the most easiest, you can for the rest
make it as nice as you want.

(For this we get a reply from Herfried as usual).

Cor
 
thanks.


Cor Ligthert said:
Elton,

You are not the first who asked this, but why not call just the event that
you want to do with the click than to perform the click.

MyEvent(nothing,nothing) is mostly the most easiest, you can for the rest
make it as nice as you want.

(For this we get a reply from Herfried as usual).

Cor
 
i do something else


in all the projects i write i only use the events as callers to my methods
this makes life a lot easier :-)



example ?


so instead of this

Private Sub btnSavePicture_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles _
btnSavePicture.Click
' Compose the picture's base file name.
Dim file_name As String = Application.ExecutablePath
file_name = file_name.Substring(0, _
file_name.LastIndexOf("\bin")) & _
"\test."

' Get a Bitmap.
Dim bm As Bitmap = picImage.Image

' Save the picture as a bitmap, JPEG, and GIF.
bm.Save(file_name & "bmp", _
System.Drawing.Imaging.ImageFormat.Bmp)
bm.Save(file_name & "jpg", _
System.Drawing.Imaging.ImageFormat.Jpeg)
bm.Save(file_name & "gif", _
System.Drawing.Imaging.ImageFormat.Gif)

End Sub




i do this


Private Sub btnSavePicture_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles _
btnSavePicture.Click

SavePicture()
End Sub

private sub SavePicture ()
' Compose the picture's base file name.
Dim file_name As String = Application.ExecutablePath
file_name = file_name.Substring(0, _
file_name.LastIndexOf("\bin")) & _
"\test."

' Get a Bitmap.
Dim bm As Bitmap = picImage.Image

' Save the picture as a bitmap, JPEG, and GIF.
bm.Save(file_name & "bmp", _
System.Drawing.Imaging.ImageFormat.Bmp)
bm.Save(file_name & "jpg", _
System.Drawing.Imaging.ImageFormat.Jpeg)
bm.Save(file_name & "gif", _
System.Drawing.Imaging.ImageFormat.Gif)
end sub
 
good idea.

Elton

Michel Posseth said:
i do something else


in all the projects i write i only use the events as callers to my methods
this makes life a lot easier :-)



example ?


so instead of this

Private Sub btnSavePicture_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles _
btnSavePicture.Click
' Compose the picture's base file name.
Dim file_name As String = Application.ExecutablePath
file_name = file_name.Substring(0, _
file_name.LastIndexOf("\bin")) & _
"\test."

' Get a Bitmap.
Dim bm As Bitmap = picImage.Image

' Save the picture as a bitmap, JPEG, and GIF.
bm.Save(file_name & "bmp", _
System.Drawing.Imaging.ImageFormat.Bmp)
bm.Save(file_name & "jpg", _
System.Drawing.Imaging.ImageFormat.Jpeg)
bm.Save(file_name & "gif", _
System.Drawing.Imaging.ImageFormat.Gif)

End Sub




i do this


Private Sub btnSavePicture_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles _
btnSavePicture.Click

SavePicture()
End Sub

private sub SavePicture ()
' Compose the picture's base file name.
Dim file_name As String = Application.ExecutablePath
file_name = file_name.Substring(0, _
file_name.LastIndexOf("\bin")) & _
"\test."

' Get a Bitmap.
Dim bm As Bitmap = picImage.Image

' Save the picture as a bitmap, JPEG, and GIF.
bm.Save(file_name & "bmp", _
System.Drawing.Imaging.ImageFormat.Bmp)
bm.Save(file_name & "jpg", _
System.Drawing.Imaging.ImageFormat.Jpeg)
bm.Save(file_name & "gif", _
System.Drawing.Imaging.ImageFormat.Gif)
end sub
 
Back
Top