Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

This is a subroutine which i thought would show another form, (but keep the current form open) but this dosent work, what is wrong with this sub routine

Private Sub cmdMP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMP.Click
       frmMediaPlayer.Visible = True
   End Sub

Edited by cdoverlaw
Posted

Form frmMediaPlayer=new frmMediaPlayer();
frmMediaPlayer.Show();

I don't know what VB would be but there is how I would do it in C#.

 

It is very similar in VB. If you just look around the code you will see examples.

C#
Posted

Ok, can someone with experience with visual basic point me in the right direction because i am thick, lol, nah its coz i cant seem to work it out,

Thanks for trying to help aewarnick, what is c# like, is it better than vb.net and is it easy to learn, i still need help with this vb.net problem though as it would take to long to convert my windows sidebar to c#

 

Jonathan

Posted

Ok, problem fixed, all i need now is to know how to make the file the form has open to close when the form is closed

 

Incase you want to know i used this code

Dim frmMP As New frmMediaPlayer
       frmMP.Show()

  • *Experts*
Posted

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

End Sub

You can get the code for the event in VS.NET by going to the code view, from the object dropdown on the top left of the code editor select FormName Events and then from the combo to the right select the event, it will automatically add the code for you.

Posted (edited)

How do i get it to close the file though

i have this code so far

Private Sub frmMediaPlayer_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

   End Sub

Edited by cdoverlaw
Posted

"then call Show() not Visible"

Sorry, forgot that Show makes Visible true. It is just easier.

Thanks for reminding me compturon.

 

Look into the Process class. Lot's of posts here about it. Do a search.

C#
Posted

my program keeps the original form open while opening a second form which then needs to close leaving only the original form, the problem is that the form that needs to close continues to play the file that was opened in the form, so i need to make it close the file and then close the form (i have got the closing of the form to work, just not the closing of the file)

 

I tried this code

 

FileClose()

[code]

 

but this dosent work

Posted

Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
       OpenFileDialog1.ShowDialog() 'display Open dialog box
       If OpenFileDialog1.FileName <> "" Then
           Try
               AxWindowsMediaPlayer1.URL = OpenFileDialog1.FileName
           Catch
               MsgBox("Error opening media file.")
           Finally
               FileClose(1) 'close file
           End Try
       End If
   End Sub

This is my opening code

The files are media files, .mp3, .mpeg etc

Posted

Thanks, lol why didnt i think of that, i must be getting thicker in my old age (and i am only 16 lol).

I had to put it in the form exit sub routine, it wouldnt work on the form closing sub routine

 

Anyway can you please tell me where i can fine out how to control every aspect of the media center control (like make it go full screen, set the media file to repeat etc)

Posted

This is a VERY painful thread to work through.

 

To open a new form (lets say its called frmMain):

 

dim frmMainInstance as frmMain
frmMainInstance = new frmMain
frmMainInstance.show

 

To close it, maybe you have a button or something, use:

me.close

or

frmMainInstance.Close()

 

That closing function is an event and you can put code in their when your form starts to close.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...