Add String To Collection In Settings?

Aug 17, 2011

i have an app, and i want to add a string into a collection in my.settings.'there is a collection: My.Settings.items

My.settings.items.add("string")

'this gives a nullreferenceexception

Dim selected() as string = {"string")
My.settings.items.addrange(selected)

'also a nullreferenceexception so, it turns out you can't do anything.how do I add the "string" into "items"?

View 9 Replies


ADVERTISEMENT

ListBox Load Settings From String Collection?

Feb 26, 2009

I'm trying to create a favorite box in my web browser using this code in Favorites.vb

Public Class favorites
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

[Code]....

Now I have it so when you click the add button it will put the URL in the string FavList, and place the URL in Listbox1 however I have no idea how to save it, and load it.

So the next time the user opens it, it will have the URL in the string and URL box, so when they click the URL in listbox1 it will redirect the WebBrowser. I think it works like that already I just need to know how to save it, and load it.

View 2 Replies

Save A Collection Of Key/value Settings In My Application's "user Settings"?

Apr 14, 2008

I'm trying to save a collection of key/value settings in my application's "user settings" (they're column widths), but while I see no errors, when I run the code (in the IDE) my collection in "My.Settings" is always nothing at startup. I do a "My.Settings.Save" when the application exits, and barring the "serializers not found" errors in the IDE, no other errors occur. When I run my application as an exe, it behaves the same way..

View 7 Replies

Asp.net - Use A Dictionary-like Collection As An Application Settings Object?

Jun 8, 2009

I'd like to store a set of key/value pairs in the application settings of my ASP.NET web app, but I'm not finding a straightforward way to do that. For example, these two questions tell me that StringDictionary etc. won't serialize to XML and suggest that I'll have to roll my own implementation. But it seems like this should be easier to do; after all, web.config is XML and < applicationSettings> is essentially a collection of key/value pairs, so it feels like I'm missing something obvious. Given my specific case below, do I really have to roll my own serialization, or is there an easier workaround?

The web app in question is a basic contact form that sends email to different recipients based on the value of a parameter; e.g. [URL]...The goal is to be able add or remove recipients (or change their addresses) by editing the web.config file so that I don't have to recompile and can easily maintain different configurations in test and production environments. For example:

// I can use something like this for the sender address SmtpMsg.From = New MailAddress(My.Settings.EmailSender)

// And then just edit this part of web.config to use different addresses in different environments.
<setting name="EmailSender" serializeAs="String"> <value>webcontact@exampledomain.com</value>

[Code]...

View 2 Replies

VS 2008 System.Collection.Hashtable In Project Settings?

Mar 24, 2010

I've defined a setting called CustomActions as a System.Collection.Hashtable. I also have a form with two textboxes (Name & CommandLine) that I want to add as a Key/Value pair to the CustomActions settingHowever, when I come to add the kvp to Hashtable I get the dreaded "Object reference not set to an instance of an object". I know what the error means I just don't see why it's relevant here.

Dim CustomActionForm As New DefineCustomAction
If CustomActionForm.ShowDialog = System.Windows.Forms.DialogResult.OK ThenMy.Settings.CustomActions.Add(CustomActionForm.txt_CAName.Text,

[code].....

View 1 Replies

How To Convert Collection To String

Jan 3, 2012

I am trying to convert a collection to a string. When I am done, it should look like String() = {"File1.Tif", "File2.Tif", "File3.tif", "MergeTiffImages.Tif}. Here is what I have so far.

Dim FileArray(0) As String
Dim Count1 As Integer
Count1 = 0
For Each k In S
ReDim Preserve FileArray(Count1)
FileArray(Count1) = """" & k & """"
Count1 = Count1 + 1
Next
FileArray(Count1) = """MergedTiffFile.Tif"""

I am getting the error "Index was outside the bounds of the array." because FileArray is a string and not an array.

View 15 Replies

String Breaks To Collection?

Apr 23, 2009

heres my situation and what i need done, will follow with code that sort of works

1. read a text file into a string2. for each word in string, append word to collection3. sort collection and remove duplicates4. check collection against existing collection and remove found items5 output final collection to text file

heres the code i have now, it inputs text to rich text box, replaces spaces with enter's and exports to text file, the reads file line by line to a collection and sortes and removes duplcates but takes way to long, mises words, locks up, ....it would also be helpful to remove all numbers and puntuation (anything not a-z)

[Code].....

View 5 Replies

String Collection To Variables?

Feb 15, 2011

I have a collection of strings that I got from splitting another string. I now need to get each value of the collection into seperate strings.[code]...

View 8 Replies

Asp.net - Load The Values From A String Into A Collection?

Jan 14, 2011

i have a string = "/a/value1/x/valueforx/b/value2/c/value3"

the keys a, b, and c can be in any order in the string that is coming in and will always be separated by a slash.

What i need to do is to find a, b, c and then add their values to a collection

View 5 Replies

Build A String From A Collection With Linq?

Oct 8, 2009

I'm building flat file content from collections of strings.

Example collection: A, B, C, D, E, etc.

I want to be able to output these values to a string with line feeds in one swoop with Linq if possible.[cod]e...

View 8 Replies

Check If A String Collection Is Empty?

Aug 19, 2009

How can i check if a string collection is empty? I tried

VB.NET
My.Settings.IPBank.Count = 0
But it said

Quote:

Object reference not set to an instance of an object.

View 6 Replies

Creating A String From A Collection Of Objects?

Oct 4, 2010

I have a question. I have a class of Cars that I need to display in a simpli-ish string if they will be sold or not base on their number.

[Code]...

I'd like to display a simple string like this:Cars to be sold: 1, 3-5, 7-8, 11, which is based of the .Sell value.Is there some kind of heuristic to create this kind of string in .NET or is it just a bunch of for/each and if/then and redimming of arrays?

View 2 Replies

Passing String From A Collection (2 Forms)?

Apr 8, 2012

I'm sure you've all seen this a lot before (in a variety of forms) but I think (hope) it's a bit different. <Not actual names of variables>I have two forms (form1 and form2). Form1 has 2 class-level variables, a string (m_String) and a collection(colCollection).Inside form1, the collection is loaded using a key. With an if-statement, the collection is matched to input (from a combobox) through the matching key.The chosen string from the collection is then passed to the m_String (confirmed with MessageBox.Show(m_String)

View 5 Replies

Remove Duplicates From A String Collection?

Apr 23, 2010

This seems like a simple question, How do i remove duplicates from a string collection?

View 12 Replies

Save The String Collection For A AutoCompleteHistory?

Jun 4, 2010

I'm wondering what the best method is to save the string collection for a AutoCompleteHistory

I do use the feature for Textfield and I can store the entered data in the collection, however I'm not sure how to save this string now

Code:
If Not AutoCompleteHistory.Contains(txtDeviceName.Text.Trim) Then
AutoCompleteHistory.Add(txtDeviceName.Text.Trim)
End If

Do I need to loop through the collection and write the content line by line to a file manually?

View 7 Replies

Textbox Autocomplete String Collection?

Jun 30, 2010

I have made taken one textbox in form, in which i have written following logic in Got Focus event.

When i focus on that its automatically showing all the suggested name from database field.

Private Sub CustomerName_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CustomerName.GotFocus
da = New SqlDataAdapter("Select CustomerName from CustomerMaster", myConnection)
da.Fill(ds, "CustomerMaster")

[Code]...

View 1 Replies

Turning A File Into A Collection Of String?

Jan 17, 2010

Notice that some files use vbnewline, some use unicode encoding, and so on and so on.

View 1 Replies

.net - Use A String In My.Settings?

Aug 10, 2011

For Each i In web
web(i) = My.Settings.sweb(i)
name(i) = My.Settings.sname(i)
Next

This code doesn't work, it is what I want to do. How do I make it so that I can change the name in my.settings without hard coding it?Basically I want to be able to change the name of the input to my.settings How can I make the "sweb" part of My.Setting a variable so I can change it.

View 3 Replies

Cannot Properly Load A String Collection Into A Listbox

Apr 2, 2009

I'm creating an open-source web browser in VB.NET Express 2008 and I've created a User Setting named History to save a collection of strings for the browsing history. However, when I try to load the history form at runtime, only the first item (of the three I added) shows up in the listbox. Below are both examples of code I have tried to use to accomplish this task.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox1.DataSource = My.Settings.History

[Code]....

View 4 Replies

Get A Collection Of All Links And Images In An Html String?

Feb 21, 2010

I'm trying to get all <A> and <IMG> tags from the webresponse I got from [URL]. Basically Im trying to get a collection of all links and images in an html string.

View 1 Replies

Store Items In A Collection In String Array?

Sep 2, 2009

I have a string array called m_DirFileList and a collection called myFileCollection. I'm trying to loop through the items in the collection and store each one in the string array. It's not working though.

[code]...

View 2 Replies

Storing Items In A Collection In A String Array?

Sep 28, 2009

I have a string array called m_DirFileList and a collection called myFileCollection. I'm trying to loop through the items in the collection and store each one in the string arrayIt's not working though. This is what I'm trying to do:

Dim myFileCollection As Collection = clsFTPClientClass.GetFileList(fileFilter, True)
intItems = clsFTPClientClass.GetFileList(fileFilter, True).Count()

[code].....

View 2 Replies

String Collection - Reads Each Line From A File

Jul 7, 2009

The code below reads each line from a file and if the conditions become true it adds the contents of the file from the particular line and after into a string collection (i.e. the All contents). This is what at least what the code should do as the current one only adds the line that it encounters into the string collection.

View 5 Replies

String Variable From My.settings?

Apr 21, 2011

I'm going to describe what I'm trying to do and then what I'm doing in hopes of making this as clear as possible.I'm trying to create a way of having data avaialble to the application that could be changed in the future and not have to recompile the code.Normally I do this for my connection strings incase something changes, this way I can just change the file and I'm good.however in this case I'm trying to store a long string variable that contains something like(including all " in the string) "Dear " + emailRecp + vbCrLf + "Thank you for buying our product...."

Now when I do this as part of the code with something like strMessage = "Dear " + emailRecp + vbCrLf + "Thank you for buying our product...."when I look at the output from this it looks like (which is what I want):

Dear Mr Smith

Thank you for buying our product....

however when I do strMessage = My.Settings.purchaseMessage (even with .ToString()) the output looks like Dear " + emailRecp + vbCrLf "Thank you for buying our product....how to do this in another manner that won't affect performance.I have also tried to trim the " from the first and last char positions and no luck.

View 5 Replies

Add Item To System.Collections.Specialized.String Collection When It Is Not Already There?

Dec 29, 2010

How can I have it so that you can add items to a System.Collections.Specialized.String Collection but only if it is not there already? I have already found the code, but deleted it and cannot remember it. It is something like[code]....

View 9 Replies

Linq Query To Compare If Collection Contains List Of String?

Feb 3, 2012

I am using a path comparison to find any children tags which works well when there is only 1 tag selected. This is my code for when multiples tags are selected but it is not working. Can you point me in the right direction?

Single Tag Selection (working)
Dim tagpath = uxTags.SelectedItem.Text
lnqCases = From i In lnqCases Where i.HelpDeskTagItems.Any(Function(x)

[code]...

View 1 Replies

Remove Items From Microsoft.VisualBasic.Collection Where Key Contains String?

Jun 1, 2011

I have a Microsoft.VisualBasic.Collection where they keys are

"123,A"
"123,B"

Is there a way to remove all keys where they begin with 123?

View 1 Replies

Connection String In Application Settings

Jan 14, 2010

I'm trying to give my users the option to move their database to a different location, currently the datasource is set as an (Application Connection String) in the Project Settings, I know that when the scope is set to "Application" it cannot be modified but I'd like to know if there's a way for me to edit the location through code of my database in the application settings without crashing the program, can this be done? The purpose is to give whoever uses my application the freedom to choose where the database should be.

View 3 Replies

Save String Array To Settings?

Jun 4, 2011

Here's the code i've used in the past to save an integer array to settings (The setting being listed as a String on the dropdown):

Save:

vb

sec0string = String.Join(";", Array.ConvertAll(sec0, Function(n) n.ToString()))

Load:

vb
sec0string = My.Settings.sec0
sec0 = Array.ConvertAll(sec0string.Split(";"c), Function(s) Convert.ToInt32(s))

View 8 Replies

Load Event Of Form To Populate Autocomplete String Collection?

May 26, 2010

I am using the following code in the load event of my form to populate autocomplete string collection but it gives me DBNULL error. Is there any other workaround where it skips DBnull values?

[Code]...

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved