0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【VB.NET】外部のリソースファイルを読み込む方法

Last updated at Posted at 2023-10-30

リソースファイルを作成する

プロジェクトタブ > 新しい項目の追加 をクリックする。
ウィンドウが出たら、リソースファイルを選択して追加する。
image.png

リソースを追加する

ソリューションエクスプローラーでリソースファイルをダブルクリックすると、編集ができる。
image.png

リソースを読み込む

ソースに以下を追加する。

Imports System.Resources
':
Dim asm As System.Reflection.Assembly
asm = System.Reflection.Assembly.GetExecutingAssembly()    ' コンパイル済みのコード群(アセンブリ)を取得
Dim rm As New ResourceManager("manageBusinessCardApp.ResourceLogin", asm)

' リソースの取得
dim strResx as String = rm.GetObject("リソースの名前")

Dim rm As New ResourceManager()

第1引数:プロジェクトのデフォルトの名前空間.リソースファイル名
何を書いたらいいかわからない場合、リソースのデザイナーファイルにResourceManager変数を定義している部分があるので、それを参考にして書く。
image.png

第2引数:現在実行中のアセンブリ。

GetObject("リソースの名前")

"リソースの名前"は、リソースを追加した時の名前を記述する。
image.png

参考サイト

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?