|
| Author |
Message |
HardySpicer
Joined: 20 Nov 2007 Posts: 5
|
Posted: Tue Nov 20, 2007 1:15 am Post subject: Simple Button Question |
|
|
I have the following call from a Button1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim strMp3 As String
strMp3 = "chop2.mp3"
Me.AxWindowsMediaPlayer1.URL = strMp3
End Sub
This works fine as part of a larger program and the Mp3 file plays.
However, if I want to automatically push the button in the code how do
I do this?
I tried
Button1_click ()
but it complains tyhat a declaration is expected? How do I do this...
regards
Hardy
Archived from group: microsoft>public>vb>syntax |
|
| Back to top |
|
 |
HardySpicer
Joined: 20 Nov 2007 Posts: 5
|
Posted: Tue Nov 20, 2007 3:45 am Post subject: Re: Simple Button Question |
|
|
On Nov 20, 5:15 pm, HardySpicer wrote:
> I have the following call from a Button1
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> Dim strMp3 As String
>
> strMp3 = "chop2.mp3"
>
> Me.AxWindowsMediaPlayer1.URL = strMp3
> End Sub
> This works fine as part of a larger program and the Mp3 file plays.
>
> However, if I want to automatically push the button in the code how do
> I do this?
>
> I tried
>
> Button1_click ()
>
> but it complains tyhat a declaration is expected? How do I do this...
>
> regards
>
> Hardy
Actually I think the answer is
Button1.Enabled=True
but it doesn't work! It does accept the code provided it is within
another sub.
Hardy |
|
| Back to top |
|
 |
"Jan Hyde
Joined: 04 Oct 2007 Posts: 466
|
Posted: Tue Nov 20, 2007 2:07 pm Post subject: Re: Simple Button Question |
|
|
HardySpicer 's wild thoughts were
released on Mon, 19 Nov 2007 22:45:37 -0800 (PST) bearing
the following fruit:
>On Nov 20, 5:15 pm, HardySpicer wrote:
>> I have the following call from a Button1
>>
>> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles Button1.Click
>> Dim strMp3 As String
>>
>> strMp3 = "chop2.mp3"
>>
>> Me.AxWindowsMediaPlayer1.URL = strMp3
>> End Sub
>> This works fine as part of a larger program and the Mp3 file plays.
>>
>> However, if I want to automatically push the button in the code how do
>> I do this?
>>
>> I tried
>>
>> Button1_click ()
>>
>> but it complains tyhat a declaration is expected? How do I do this...
>>
>> regards
>>
>> Hardy
>
>Actually I think the answer is
>
>Button1.Enabled=True
>
>but it doesn't work! It does accept the code provided it is within
>another sub.
That code isn't even VB, it's VB.Net, this is a VB6 group
you need a group with 'dotnet' in the name.
--
Jan Hyde
https://mvp.support.microsoft.com/profile/Jan.Hyde |
|
| Back to top |
|
 |
Larry Serflaten
Joined: 04 Oct 2007 Posts: 2644
|
Posted: Tue Nov 20, 2007 2:56 pm Post subject: Re: Simple Button Question |
|
|
"HardySpicer" wrote
> > However, if I want to automatically push the button in the code how do
> > I do this?
> Actually I think the answer is
>
> Button1.Enabled=True
>
> but it doesn't work! It does accept the code provided it is within
> another sub.
In VB6, the button event would be called if you set its Value property
to True (Button1.Value = True), but there is no Value property for
the .Net buttons. (See PerformClick method)
Classic Visual Basic (VB6 and prior) is significantly different than
the later (.Net) versions. The .Net languages have their own newsgroups
for discussions.
Try posting in: microsoft.public.dotnet.languages.vb
As an aside, wouldn't it be easier to put the play code in a separate
routine, and then call on it as needed (from the button click, or
wherever else) ???
LFS |
|
| Back to top |
|
 |
Derik
Joined: 22 Dec 2007 Posts: 5
|
Posted: Sat Dec 22, 2007 2:41 am Post subject: Re: Simple Button Question |
|
|
Um, try Button1.SetFocus. I think that works.
HardySpicer wrote:
> I have the following call from a Button1
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> Dim strMp3 As String
>
> strMp3 = "chop2.mp3"
>
> Me.AxWindowsMediaPlayer1.URL = strMp3
> End Sub
> This works fine as part of a larger program and the Mp3 file plays.
>
> However, if I want to automatically push the button in the code how do
> I do this?
>
> I tried
>
> Button1_click ()
>
> but it complains tyhat a declaration is expected? How do I do this...
>
> regards
>
> Hardy |
|
| Back to top |
|
 |
Ken Halter
Joined: 04 Oct 2007 Posts: 4150
|
Posted: Thu Dec 27, 2007 12:14 pm Post subject: Re: Simple Button Question |
|
|
"HardySpicer" wrote in message @e23g2000prf.googlegroups.com...
>I have the following call from a Button1
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
There's no reason to "click" the button with code. It's not as if calling
the routine is going to visually cycle the button down, then up.
Create an entirely new procedure (about 3 seconds of work) and call that
procedure from the click event and anywhere else you need it....
Then, keep in mind that, since you guys seem to be taking some kind of "VB"
class, this and all other groups on the MS server that start with
"microsoft.public.vb" are here to support pre-dotNet versions of VB....
which means, the code we post in an attempt to help will probably be VB6
code and, there's a great chance it won't work in any version of dotNet.
--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm
|
|
| Back to top |
|
 |
|