0
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    If ComboBox1.SelectedText = "Anaheim" Then Dim finalpath As String = "C:\hockey055f\data\model\ice0.png"
    My.Resources.anaice.Save("C:\hockey055f\data\model\ice0.png")
    MsgBox("Installed!", MsgBoxStyle.Information, "Installed by GoLeafsGo")

    ElseIf ComboBox1.SelectedText = "Boston" Then If System.IO.File.Exists("c:\hockey055f\data\model\ice0.png") Then 
    System.IO.File.Delete("c:\hockey055f\data\model\ice0.png")
    My.Resources.bosice.Save("C:\hockey055f\data\model\ice0.png")
    MsgBox("Installed!", MsgBoxStyle.Information, "Installed by GoLeafsGo")
End Sub

这是我的代码。我正在尝试这样做,以便当用户在组合框中选择一个项目并且用户按下按钮时,该文件将从我的资源传输到上面显示的目录。当我单击第一个值(阿纳海姆)时,文件“anaice.png”被传输,但随后(波士顿)值中的“bosice.png”被放入并覆盖另一个图像。请帮忙!

4

1 回答 1

1

试试这个,但我不知道这是不是你想要的:

private finalpath As String = "C:\hockey055f\data\model\ice0.png"
private res = nothing

private sub ComboBox_Selectedindexchanged(sender As Object, e As EventArgs) _
handles ComboBox1.Selectedindexchanged

    Select case sender.Selectedindex

        case is 0:res= My.Resources.anaice
        case is 1:res= My.Resources.bosice
        case else
             msgbox ("select case is out of range")

    end select

end sub

Private Sub Button1_Click(sender As Object, e As EventArgs) _
Handles Button1.Click

    try:io.File.Delete(finalpath):catch:end try
    res.Save(finalpath)

    MsgBox("Installed!", MsgBoxStyle.Information, "Installed by GoLeafsGo")

End Sub

PS:代码是即时编写的,可能包含语法错误。

于 2013-10-19T20:05:28.550 回答