×

VB VB.NET

VB.Net My.Resource的使用方法

Kalet Kalet 发表于2019-07-23 09:43:22 浏览442 评论0

抢沙发发表评论

 

在右侧Resources中一共保存有一个.wav的声音文件和一个.ico的图标文件,以下代码演示如何调用Resources中的文件资源

Public Class Form1

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        Dim s As String = My.Resources.ExitHint

        If (MsgBox(s, MsgBoxStyle.YesNo) = MsgBoxResult.No) Then
            e.Cancel = True
        End If
    End Sub

'更多vb.net源代码和实例,请关注乐博网lob.cn

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Icon = My.Resources.Icon1
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        My.Computer.Audio.Play(My.Resources.ding, AudioPlayMode.Background)
    End Sub
End Class

作者:Iva    来源:乐博网收集

群贤毕至

访客