您的位置:学习中国 推荐教程 VB编程 正文
原作者:kuku 添加时间:2007-06-02 原文发表:2007-06-02 人气:44 来源:互联网

本文章共28074字,分19页,当前第16页,快速翻页:
 
-----------------------------------------------------------------------------------------------------------------------------------------------

本文提示:《vb.net例程集锦(16)》是本站编辑们为广大网友精选的实用文章,本文阐述了关于文章的相关理论,相对来说专业性强,但是本文只是针对于某个问题提出的见解与论述,未必能辐射到相关问题的方方面面,所以本文处理问题的方法仅仅为您提供一些参考。更多问题请查阅学习中国网其他栏目哦.

-----------------------------------------------------------------------------------------------------------------------------------------------


components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private components As System.ComponentModel.IContainer
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Private Sub InitializeComponent()
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.SuspendLayout()
\'
\'ListBox1
\'
Me.ListBox1.Location = New System.Drawing.Point(8, 8)
Me.ListBox1.Name = \"ListBox1\"
Me.ListBox1.Size = New System.Drawing.Size(272, 212)
Me.ListBox1.TabIndex = 0
\'
\'Form1
\'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 238)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ListBox1})
Me.Name = \"Form1\"
Me.Text = \"Form1\"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim SoundDeviceQuery As New SelectQuery(\"Win32_SoundDevice\")
Dim SoundDeviceSearch As New ManagementObjectSearcher(SoundDeviceQuery)
Dim SoundDeviceInfo As ManagementObject
For Each SoundDeviceInfo In SoundDeviceSearch.Get()
ListBox1.Items.Add(\"Sound Device Description: \" & SoundDeviceInfo(\"Caption\").ToString())
ListBox1.Items.Add(\"Sound Device Status: \" & SoundDeviceInfo(\"status\").ToString())
ListBox1.Items.Add(\"Sound Device Manufacturer: \" & SoundDeviceInfo(\"Manufacturer\").ToString())
Next
End Sub

End Class


如何得到资源文件中的文件
在应用程序里嵌入资源,可以避免用户因删除资源文件而造成应用程序出现错误。要使用资源文件中的文件,只需要按下面的方法调用即可:

VB.NET
Function GetEmbeddedResource(ByVal strname As String) As System.IO.Stream
Return System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(strname)
End Function

C#
System.IO.Stream GetEmbeddedResource(string strname){
return System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(strname) ;
}

其中的参数strname必须是下面的格式:..,比如: \"MyApplication.Icon1.ico\"。参数是大小写敏感的。如果不正确或者缺少文件,将会出现返回Null的错误。

要在你的引用程序中嵌入文件,只需要按下面的步骤操作即可:

1,在资源管理器里选中文件

2,按住鼠标左键,拖到工程文件上,松开鼠标左键。

3,在拖放的文件上点鼠标右键,选“属性”

4,在生成操作里选择“嵌入的资源”。

在进行测试之前,请准备好以下几个文件:1.ico,2.ico,Text.rtf,xsl.txt,rose.jpg,Test.jpg,结果如下:



下面是完整的例子:


\' 模块文件
Module Module1
\'VB.NET
Function GetEmbeddedResource(ByVal strname As String) As System.IO.Stream
Return System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(strname)
End Function

\'C#
\'System.IO.Stream GetEmbeddedResource(string strname) {
\'return System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(strname) ;
\'}
End Module

\' 主文件
Public Class Form1
Inherits System.Windows.Forms.Form
 
本文章更多内容<<上一页 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 下一页>>
本页地址
收藏到:[收藏夹] [百度搜藏] [新浪ViVi] [POCO网摘] [ 和讯网摘] [好哦网摘] [Google书签]
               
[搜狐网摘] [365Key网摘] [天极网摘] [我摘] [博采网摘] [igooi网摘]
相关文章

在VB.NET中获得功能加强的分类和查询数组
解析Visual Basic.NET事件编程
VB.NET中对象的克隆
VB.Net编程入门之Hello World 入门篇
VB 神童教程第二章第九节——综合示例三
VB 神童教程第二章第八节——组合框控件
VB 神童教程第二章第七节——列表框控件
VB 神童教程第二章第六节——综合示例二
VB 神童教程第二章第五节——单选与复选控件
VB 神童教程第二章第四节-CommandButton控件
向SQL Server数据库添加图片和文字
多个窗体之间如何互相调用
如何拖动没有边框的窗体?
怎么让窗体透明后,控件不透明?
Video/ Audio压缩数据流播放技术
VB程序中处理随机事件
VB编程的必备技巧
VB6制作Win98风格的工具栏
VB实现窗口的弹出式菜单
用VB6实现动态增减控件

相关评论


本文章所属分类:首页 推荐教程 VB编程   VB编程