[英]Add a image file in resources using VB code
I would like to know if there is any way to add a local file as resource using VB code. 我想知道是否可以使用VB代码将本地文件添加为资源。 Its an image file .
它是一个图像文件。 Normally I go to Project -> Project1 Properties -> Resources -> Add Resource -> Add Existing File -> and select my executable.
通常我去Project-> Project1 Properties-> Resources-> Add Resource-> Add Existing File->并选择我的可执行文件。 I would like to do the above using Visual Basic code.
我想使用Visual Basic代码来完成上述操作。 Does anybody have any idea?
有人知道吗?
Last time I added a resource into my VB program I did the same as you have mentioned above, recently I went to do the same thing and found I had to search for the location and most replays to this question told you what to do but did not show the steps nor the screen which was kinda confusing. 上一次我将资源添加到VB程序中时,我做的与您上面提到的相同,最近我去做同样的事情,发现我必须搜索位置,大多数重播此问题告诉您该怎么做,但是做了没有显示步骤,也没有显示屏幕,这有点令人困惑。 I hope the following helps.
希望以下内容对您有所帮助。
Visual Studio 2017: Visual Studio 2017:
Add your file. 添加文件。 In the solution explorer a resources tab will now be visible with your file listed, in my example I added two sound files bite.wav and moan.wav (sorry not an image file).
在解决方案资源管理器中,现在将显示资源选项卡,其中列出了您的文件,在我的示例中,我添加了两个声音文件bite.wav和moan.wav(对不起,不是图像文件)。 These sound files were compiled into my executable and I executed the sounds in the program with the following:
这些声音文件被编译到我的可执行文件中,并使用以下命令在程序中执行声音:
My.Computer.Audio.Play(My.Resources.Moan, AudioPlayMode.Background) 'Play audio file in background do not halt program
Your resource should now be able to be seen if you enter 'My.Resources.' 如果您输入“我的资源”,现在应该可以看到您的资源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.