Results 1 to 7 of 7

Thread: Regarding the usage of resource file in VB.NET

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    10

    Regarding the usage of resource file in VB.NET

    Hi,

    i want to know how to store a icons and images in a resource file. Also the method to load it from there and display it in picturebox in vb.net.

    Thanks,
    Ganesh

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Regarding the usage of resource file in VB.NET

    Here something I knocked up to control getting them out easily.

    VB Code:
    1. 'Somewhere public
    2. Friend MyResFile As New Resources.ResourceManager("resMyResFile", GetType(modNameOfModuleDeclaredIn).Assembly)
    3.  
    4.         Friend Function LoadResString(ByVal ResourceNumber As Integer) As String
    5.  
    6.             Dim strReturn As String
    7.  
    8.             strReturn = MyResFile.GetString(ResourceNumber.ToString)
    9.             If strReturn Is Nothing Then
    10.                 strReturn = ""
    11.             End If
    12.             Return strReturn
    13.  
    14.         End Function
    15.  
    16.         Friend Function LoadResPicture(ByVal ResourceString As String) As System.Drawing.Image
    17.             Return CType(MyResFile.GetObject(ResourceString), System.Drawing.Image)
    18.         End Function
    Last edited by Grimfort; Oct 16th, 2006 at 11:19 AM.

  3. #3
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Regarding the usage of resource file in VB.NET

    if you are using VB.NET 2005, they have made it much easier to use resource files by way of the My namespace...

    Say you added an image to your project as a resource, and the image was of a house, which you gave the label "HOUSE" you would access it in code like

    VB Code:
    1. picturebox1.Image = my.Resources.HOUSE

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    10

    Re: Regarding the usage of resource file in VB.NET

    Hi,

    Thanks for your replies.
    whether is it possible to assign a id to each icon or image in resource file and whether we can get the image or icon using that id in VB.NET.

    Thanks,
    Ganesh

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Regarding the usage of resource file in VB.NET

    Are you using VB 2005?

  6. #6

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    10

    Re: Regarding the usage of resource file in VB.NET

    yes i am using VS2005.

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Regarding the usage of resource file in VB.NET

    then you can do it just how I said in post #3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width