Adding Resource By Name (String Variable)
Jan 18, 2010I have a couple of pictures in my resources. I know that I can set an image by:
picturebox1.image=my.resource.picture1
But how can I add an image if I hold its name in a string variable?
I have a couple of pictures in my resources. I know that I can set an image by:
picturebox1.image=my.resource.picture1
But how can I add an image if I hold its name in a string variable?
I am a newbie programmer. I have some code that needs to open a file based on what is contained in a variable. Example: If File.Exists(w) Then Dim q() As String = IO.File.ReadAllLines(w)
The problem is that I need the variable "w" , after readallLines , to have a .txt extension. I tried this:
IO.File.ReadAllLines(w & ".txt") but that doesnt work.
I need to refer to some strings using an "indirect string" in the registry. It should be in this form:
@filename,resource
MSDN: "If the resource value is zero or greater, the number becomes the index of the string in the binary file. If the number is negative, it becomes a resource ID."How can I find out either of these numbers for my resources that only have names in VB? I also need the ID/index for the exe's icon.
I want to add an xls file as resource to my vb.net project.
I added the existing file and when i write the code which will help the user to download the file , i am not able to see the resource listed in the dropdown .
Dim b() As Byte = My.Resources.abc
System.IO.File.WriteAllBytes("C:abc.xls", b)
MsgBox("abc downloaded in C:", MsgBoxStyle.Information, "Project")
I'm looking for a way to search a string variable for two words and copy the text in between them into another variable. This needs to be done as many times as the match occurs.
View 3 RepliesI've been making this BlackJack program for a school project
I have 52 image files, labelled from '_1' to '_52' in my resources folder, each number corresponds to a card.
My question is, how do I get a picture box to assign the correct resource according to a variable
So, say I have
"pictDealerCard1" -> picture box which displays the first of the dealers card
DealerCard1 = 37 -> random number generated through INT(RND() * 52)
and resource '_37'
[Code].....
basically what I want to do is compile a program from my program(parent) to a seperate program(child) which is a module I have created.
When I compile my child program from my parent program I want to add a .exe resource to the child and when the child program runs I want to run the resource I added.
I've added multi-language support to my application by setting the Localizable property of each form to True and changing the Language property to the desired one. Then I change the Culture.
vb.net System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("de-DE")
System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("de-DE")
VB automatically creates the resource files and this works all fine, but now I need to do something similar for Strings and MessageBoxes, e.g. MessageBox.Show(My.Resources.Exit). Everywhere I read that I need two resource files in order to do this, but I can't find where to add a second resource file myself.
Every forum post or google search result I found says, go to 'Project -> Add Resource', but I don't have the "Add Resource" menu option. Or they say, right click on your solution and go to 'Add -> Resource (RESX)', but I don't have a "Resource (RESX)" menu option either. When I go to 'Project -> Add New Item', there's no 'resource' option in the list either. Am I blind or does VB2010 Express not have an option to add resource files manually?
I have a simple app (coded in VB 2008 Express Edition) that uses an SQL Server database (in .mdf format) that works fine on my own machine. I created the database in SQL Server on this machine. I added the DB as a data source and it works fine. But when packaged this app (ClickOnce) and installed this app on a different machine the installer tries to download MS SQL Server Express. Obviously this is because SQL Server is a prerequisite and is not installed on the other machine. But just as obvious is the fact that the download will take a long time to complete before my code even starts installing.
My question is this: Is there an SQL Server reference (using Add Reference...) that I can add to avoid this? I suspect the application just needs one or two DLL files from SQL Server. Downloading the whole product seems like overkill. Is there a way I can included the needed files in my app to avoid this long download process?
I am very new to coding, though I can understand some of the rreeaallllyy basic stuff. However, I am currently developing a basic webbrowser and I'm stuck =. How do I take text, i.e. a TextBox's text, and save it as a string resource, but I do not want it to have that text as a name, as it can change. I want to store the URL as a string called "Home" but still have it's properties as the URL. I would also like to be able to recall it for when the program loads.
View 5 RepliesSay I have something like this
Dim Level1 as Integer = 83
Dim Goal as String
Goal = InputBox(" What level is your goal?")
[code].....
Im new at this and Im trying to insert an embedded resource into a string. However, I get an error at the last statement below. Can anyone tell me what I forgot to do or what Im doing wrong?
Peter
Imports System.IO
Imports System.Reflection
Dim oEmbed As Object
[Code]...
How do I convert a Resource to String? I dont want the Resource to be "written" or "extracted" from the program.
View 1 RepliesHow can you save a user input string to a resource? I want the user name that the user enters to be saved to a resource so that another form can use it. Or if using a module would work better, how would I do that?
View 3 RepliesHow can we add multiple columns in resource file (.res) for multi language (eg. 1st column for English and 2nd column for Chinese) through script used by rc.exe utility? We know how to add one column to resouce file using script and compile it with rc.exe it will generate one default language column with id,
[Code]...
I have a question abour string type resources and hope this is the proper place to ask it.I know how to create a string (type) resource file. I also know how one localizes this file by adding the appropriate language abbreviation (i.e., es, en, etc.) after the name of the file (i.e., str_resource.es.resource).None of this is terribly difficult. However, I haven't been able to fine how to do what I want to do.
Specifically, because I have an enormous number of strings (button labels, labels, registry strings [key_names and values, etc.), error messages and such) I would like to create multiple string resource files - one for each of these items. For example:
[URL]...
The code below works so i know the resource is registering correctly ...
vb.net
My.Computer.Audio.Play(My.Resources.alrt2xuk, AudioPlayMode.Background)
But what im trying to do is make a function where I can play the audio file in the programs resources with a string variable being passed to it representing the resource objects filename.
this is so users can type in a audio files name and pull it from the program's resources dynamically VS a big case i would keep having to expand ...
heres my code
[Code]....
but that isnt working for some reason ... keeps throwing "objects reference not set to instant of an object" on the "Return ..." line
How do I set button1.image to the image resource named in a string?
if my_string = "image1" then
button1.image = my.resources.image1
else if my_string = "image2" then
button1.image = "image2"
...
else if my_string = "image30" then
button1.image = "image30"
end if
Is there an easier way to do this?
I am trying to insert a string variable inside of two strings, and make a combined string. Public Sub Page_Load() Dim Id As String Id = Trim (Request.QueryString("Id")) End Sub Dim mp3text as string url... & Id & ".mp3" My goal is to make the mp3text variable have a string that is: url...(If Id is 7) It is for some reason not connecting up correctly. I checked what string it is outputting and this is what it is giving: url...It is missing the Id content.
View 12 RepliesI have a multi-lined string message that needs to be added to the Resources.resx file of the project. Currently I'm achieving this some thing like this MessageBox(My.Resources.MyMsg1 & vbNewLine & My.Resources.MyMsg2 ). This works.However I'd like to have the entire message in one resource string rather than adding two resources strings to the Resources.resx file.I've tried using' but no luck..message displays as "My message.Rest of the message".I've also tried manually adding a new line in the Resources.resx file. ( by doing "My message.<Shift+Enter>Rest of the message" But message is adding an additional space before the message in the second line.
View 8 RepliesIn a resource string, not one that you declare in the code, but rather in the resources itself, how do I store multiple pieces of data in it?
View 7 Repliesi have the folowing co
For x = 0 To 7 Step 1
For i = 0 To 7 Step 1
Dim rectangleShape1 As New Microsoft.VisualBasic.PowerPacks.RectangleShape() 'create a new object to assign to the array location
board(x, i) = New Microsoft.VisualBasic.PowerPacks.RectangleShape() 'create the new object in the array
[code].....
I have a master page with the following vb code in the code file...
Public Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
If Not IsPostBack Then
If Session("key") Is Nothing Then
[code]......
The code below works for the class that I hard coded "XCCustomers" in my RetrieveIDandName method where I use CType. However, I would like to be able to pass in various classes and property names to get the integer and string LIST returned. For example, in my code below, I would like to also pass in "XCEmployees" to my RetrieveIDandName method. I feel so close... I was hoping someone knew how to use CType where I can pass in the class name as a string variable.
Note, all the other examples I have seen and tried fail because we are using Option Strict On which disallows late binding. That is why I need to use CType.I also studied the "Activator.CreateInstance" code examples to try to get the class reference instance by string name but I was unable to get CType to work with that.When I use obj.GetType.Name or obj.GetType.FullName in place of the "XCCustomers" in CType(obj, XCCustomers)(i)I get the error "Type 'obj.GetType.Name' is not defined" or "Type 'obj.GetType.FullName' is not defined"
'+++++++++++++++++++++++++++++++
Imports DataLaasXC.Business
Imports DataLaasXC.Utilities
[code]....
These is the content of my txt file which is saved in D drive in my pc abc,1,2,3..I tried the flowing but it didn't work:[code]I am getting error on this line.. data = line.Split(","c)...it says this line isn't in use anymore or something and that I rather use LineInput but thats asks for filenumber and i don't know what that is. I am sorry but I am a complete beginner. what else can I try? [code]ok that error is gone now but now if I want to add these values to a list box..how can i do that?
View 1 RepliesI have a List(of String()). I have written a custom comparer (implements IComparer(of string)) to do an alphanumeric sort.Is there a way to sort the List using a given index to determine which position in the String() to sort by? In other words one time I might sort by Index = 0 and another time by Index = 3. The length of all String() in the list is the same.For reference this question is similar to Sort List<String[]> except I am using VB.net and that question is hardwired to Index=0.
EDIT from OP's comments:I started simple with the non custom comparer but I am getting an error: expression does not produce a value. Not sure what I am doing wrong.Here is the code:
Public Shared Function SortListOfStringArray(ByVal ListOfStringArray As List(Of String()), ByVal SortByIndex As Integer) As List(Of String())
Return ListOfStringArray.Sort(Function(x, y) x(SortByIndex).CompareTo(y(SortByIndex)))
End Function
Sorry for the extra long title, Here's what I want to do.I want to give the user the option of using or not using specific features of the program.If I can set a simple yes or no value that wil persist each time the program run and then depending on the variable turn off or on the feature at start
View 14 Repliesdim pvalue as datetime pvalue = (Date.Now.AddHours(3), Date.Now.AddMinutes(2))
above code getting error of ')' expected
No Error MessageBox.show(Date.Now.AddHours(3), Date.Now.AddMinutes(2))
I have a visual basic shell command that installs an IPP printers with a shell command. It asks for the username for the port.
userport = username.Text
How do I Incorporate that into:
Shell("rundll32 printui.dll,PrintUIEntry /b ""AT-LAB-BWQ"" /if /f %windir%inf
tprint.inf /r
""[URL]"" /m
""HP Color LaserJet 2800 Series PS"" /z /u")
I have some code that splits a session into strings by a -
My session looks something like this 123-456-789- and I split it like this
Dim MyString As String() = Session("MySession").Split("-"C)
And i've got a some code like this
Dim x as Integer
For x = 0 to MyString - 1
Response.write("Ref: " & MyString(x) & "<br>")
Next
This writes the code like this
Ref: 123
Ref: 456
Ref: 789
Ref:
So it's adding an extra Ref where it shouldn't be because there is no data after the last -
Is there a way to stop this adding in the extra one?