Playing flash file in vb.net - vb.net

I did some research and come up with this code.
AxShockwaveFlash1.Stop()
AxShockwaveFlash1.Movie = Application.StartupPath & "\RSAppt.swf"
AxShockwaveFlash1.Play()
playBtn.Enabled = False
I don't know why the video is not playing. My RSAppt.swf file is located at a resources(foldername) folder under my project. Is it the path? What is the right way to direct it to the specific path of my .swf file. Any ideas? Thanks!

This should work just fine.
Dim path As String = Application.Startuppath & "\yourfolder\yourfile.swf"
AxShockwaveFlash1.LoadMovie(0, path)
AxShockwaveFlash1.Play()
AxShockwaveFlash1.Loop = False
Happy Coding!!

You need to have:
AxShockwaveFlash1.Show()

Related

Downloading a file into Application path

so i am using this code to download file
Dim exePath As String = Application.ExecutablePath()
My.Computer.Network.DownloadFile(TextBox2.Text, exePath & "/img.png")
where textbox2 contains url to .png file but i get this error
Note that test.exe is on Desktop.
You can do it in this way
My.Computer.Network.DownloadFile(TextBox2.Text, Environment.CurrentDirectory & "/img.png");
Environment.CurrentDirectory Will give you the current working directory.
I hope this will work for you.

VB.Net WebClient DownloadFile Won't Save to Variable Filename?

Trying to download a website to a file using WebClient DownloadFile works fine as long as I have a preset filename for it. If the filename is variable it throws an exception and I can't work out why.
dim link as string = "http://google.com"
Dim myWebClient As New System.Net.WebClient
myWebClient.DownloadFile(link, link & ".html")
If the output is set to "site.html" it'll work just fine but I can't get it to accept a variable.
I'm passing the variable link to the sub and I want it to save that site to The-Sitename.html. I'm guessing there is something really simple I'm missing here?
You cant save a file with the website extension included in the URL
Try using the following code to exclude common extensions to hopefully fix the issue
link = link.Replace("http://", "")
link = link.Replace("https://", "")
myWebClient.DownloadFile(link, link & ".html")

get full path using openfiledialog

Simple utility to get a file for use.
Using openfiledialog I am trying to get the full path EG: File = text1.txt and it is located in c:\temp. So the full path is C:\temp\text1.txt.
But all I can get is the file name. I've searched I've hunted, I'e tried for a couple of hours and nothing works.
Here is code with comments...
'open the openfile dialog so the user can search for a file
Dim openFileDialog1 As New OpenFileDialog()
'set the root to the z drive
openFileDialog1.InitialDirectory = "Z:\"
'make sure the root goes back to where the user started
openFileDialog1.RestoreDirectory = True
'show the dialog
openFileDialog1.ShowDialog()
'check there is something to work with... the user did not exit before selecting a file etc.
If openFileDialog1.FileName.Length = 0 Then
'if the user selected a file set the value of the replacefile text box
Else
TB_ReplacementFile.Text = System.IO.Path.GetFullPath(openFileDialog1.FileName)
End If
All I get is the file name...
The MSDN documentation and numerous posts all over the place say all you need is openfiledialog.FileName. However this did not work for me, can't tell you why. What DID work is to use this:
TB_ReplacementFile.Text = System.IO.Path.GetFullPath(openFileDialog1.FileName)
This works great, I get what I need. I cannot explain why I have to do this. Not sure how I can be the problem, but that must be the problem right?!
Hopefully this helps someone.
The FileName Property returns the full path.
The file name includes both the file path and the extension. If no files are selected, this method returns an empty string ("").
If (openFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK) Then
TB_ReplacementFile.Text = openFileDialog1.FileName
End If
Not 100% sure if this would resolve the issue you're having, or if it's simply just another way to handle it, but I prefer to check the DialogResult. I.E:
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.InitialDirectory = "Z:\"
openFileDialog1.RestoreDirectory = True
If openFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.Ok Then
Console.WriteLine(openFileDialog1.fileName)
End If
this worked to get the directory or path
dim sDir as String = System.IO.Path.GetDirectoryName(openfiledialog1.FileName.ToString)

Read Extension of file in resources

How can I write a code to read the extension of a My.Resources file?
Example:
if i have a file named IMG.JPEG in my resources
How can I make msgbox to show the extension .JPEG ?
I can show the file name but without extension with this
For Each Fe In My.Resources.ResourceManager.GetResourceSet _
(System.Globalization.CultureInfo.CurrentCulture, False, True)
MsgBox(Fe.Key)
Next
any help would be greatly appreciated
EDIT:
I can get the extension of file but as .BYTE[] and pictures as .Bitmap with this code
GT = Path.GetExtension(My.Resources.ResourceManager.GetObject(Fe.Key).ToString)
MsgBox(GT)
How can i get the original extension?
If you have the filename you just need:
sExt = System.IO.Path.GetExtension(sFileName)
Or:
sExt = sFileName.SubString(sFileName.LastIndexOf("."c))

How do you load an image from resource file in vb 2010 expresss?

First of all Im new to vb 2010 and so far have enjoyed what I have been able to do with it. That being said I have run into an issue with my current project.
Basically I have created a timer and all works well on that part. My issue lies in that my timer loads a .png for each minute/second and I was linking the images like so:
Picturebox1.Image = Image.Fromfile("C:\timer\images\" & minutes.text & ".png")
Picturebox2.Image = Image.Fromfile("C:\timer\images\" & seconds.text & ".png")
So running this on another pc rendered that bit of code useless as that computer did not have those files locally and the program would end in an error as it could not find the .png files.
I did a bit of searching online and found a few sites and video tutorials how to read from the resource file. But in doing so I have been unable to make it function properly.
So this is what I found here:
Picturebox1.image = My.Resources.minutes.text
Picturebox2.image = My.Resources.seconds.text
I know this bit of code is wrong as I'm now getting 2 errors in vb 2010. The only way I have managed to make this work is to specify the file name. But what I'm wanting to do is use whats in "minutes.text" and "seconds.text" to specify the file name.
Is there a way around this? or do I have to use a bunch of if statements to do this?
example:
If minutes.text = 1 Then
picturebox1 = My.Resource._1
End If
If seconds.text = 12 Then
Picturebox2 = My.Resource._12
End If
I would hate having to do a bunch of if statements if there is a simple fix. So I've come here for help.
i think you are looking for this:
Dim currentMin as string = "_" & minutes.text ' it would look something like this: _1
picturebox1.Image = CType(My.Resources.ResourceManager.GetObject(currentMin), Image)
Dim currentSec as string = "_" & seconds.text
picturebox2.Image = CType(My.Resources.ResourceManager.GetObject(currentSec), Image)
I have tried this form, and it is functional
Picturebox1.Image = Image.FromHbitmap(My.Resources.imagename.GetHbitmap())