VS 2010 Make An Enum Of Strings?

Feb 20, 2012

I would like to make an enum of strings. There are several masks for text boxes that I would like to standardize in our system.For simplicity lets say there are 2 masks:

"PhoneNumber" which is "(999)000-0000"
"Zip Code" which is "00000-9999"

I would like to be able to reference these through out the entire program in a manner such as:

DefaultMasks.ZipCode or DefaultMasks.PhoneNumber

Since enums can not be of string type, what would your best suggestions be as to how I could do this. I had thought about a class with constants in it but I was not sure how to implement that properly.

View 14 Replies


ADVERTISEMENT

Create A Enum Or Enum Type Functionality Witch Return String (enum Returns Int) In .net

Dec 30, 2009

I have a URL lets say . some time i need to send HTTP and some time i need to send it to HTTPS for that i created a enum:

Private _protocol As Protocol

Enum Protocol
HTTP
HTTPS

[CODE]...

Now when i get value back from protocoltype it returns me integer value as enum do so tell me how to get string from enum or other substitute.

Dim targetUri As String = setting.protocolType & "://www.mysite.com"

View 1 Replies

ToString Format Strings Give Enum Value Was Out Of Legal Range?

Sep 15, 2010

In the past I've been able to pass a format string to the tostring method.It's not working any more Here's an example from my Watch window:

1.1.tostring String
1.1.tostring("0.00") {"Enum value was out of legal range."} System.ArgumentOutOfRangeException

[code]......

View 11 Replies

Check Enum Names Against Strings In A Rich Text Box And Highlight Matches?

Mar 18, 2012

learning about Enum and trying to determine if it has the right methods for what I need:

[Code]....

View 2 Replies

Asp.net - Make Enum Bindable To Datagridview

Dec 10, 2009

I have an object which contains a number of string properties and an enum property called CRAction.

I have another object which represents a collection of the above object.

When I bind the collection object to something like a gridview, all of the string properties bind fine, but the enum doesn't appear.

I have added another string property which returns CRAction.ToString, but is there a better way to make an enum bindable to a control as part of an object?

It all seems a little hackish to have another property for the same thing purely for data binding!

View 1 Replies

Enum Item - Protected Name - Statement Cannot Appear Within An Enum Body

Mar 25, 2011

I'm trying to declare an enumeration and one of the names I'd like to use for an item is not usable apparently. Where I am declaring 'STEP = 3', I get this error message in visual studio: "Statement cannot appear within an Enum body. End of statement expected." Is it possible to use STEP as an item name somehow? [Code]

View 4 Replies

ENum Names And Values Don't Match For Same ENum

Jan 2, 2012

RE - FilesystemRights Enum

This Code:

Dim FSRS As Type = GetType(FileSystemRights)
For Each fsr As String In [Enum].GetNames(FSRS)
TextBox1.AppendText(fsr.ToString & vbCrLf)
Next

View 3 Replies

VS 2010 Make Strings With "" In It?

Feb 10, 2012

how do I make strings with "" in it? Ex. " "I Love Cake" "So the "I Love Cake" stay in the string?

View 4 Replies

VS 2010 Extending An Enum?

Jun 27, 2011

I know from .NET 3.5 onwards (or might be 3.0) we can use Exension Methods to add our own methods to any Type in the .NET Framework and this is very handy, but I'm wondering if it is possible to "extend" an Enum as well?

View 13 Replies

VS 2010 String To Enum

Apr 12, 2012

[code]On my form I have text box control bind to data from sql db where for GeneralLedgerType I have only string value taken from db like "0000010" or "0000020", and when I try to run application error appears "conversion string to integer failed" and I know that I have to parse string to enum, but not sure how .

View 8 Replies

VS 2010 Finding Strings Within Strings?

Jan 8, 2012

Is there an easy way to find a certain string within a string and then return the strings that you find as an array?I have written this:

Public Function FindStrings(ByVal strSourceString As String, ByVal strStartString As String, ByVal strEndString As String) As String()
Dim StringStartposition As Integer
Dim StringEndPosition As Integer
Dim Currentposition As Integer = 1

[Code]...

View 16 Replies

VS 2010 Separate Strings Into Other Strings?

Jan 16, 2011

I have this string called time. It's value is in this format: HH:MM:SS The numbers change, but the format stays the same. I want to separtate the code into 3 strings Hour, Minutes, Seconds.

View 2 Replies

Nullable Enum Verse Enum.None?

May 26, 2010

Which is better, using a nullable enum or adding the value None=0 to your enum list?Using nullables requires more code, but I kind of like it since it forces me to think about the possibility. Otherwise I'm liable to forget about the None enum and fail to account for it being a special case.

View 11 Replies

Search An Enum Value Inside Of An Enum?

Aug 23, 2011

I've tried the code below but it always returns nothing, It should enter

Protected Function GetTotalDebitAmount(ByRef roEntryDetailRecordBaseList As List(Of PPDEntryDetailRecord)) As String
Dim iTotal As Integer = 0

[Code]....

I need some one who evaluate the part below:

If CBool(Array.IndexOf([Enum].GetValues(GetType(TransactionCodes.Debits)), CInt(oEntryDetailRecord.TransactionCode)) > 0) Then

View 1 Replies

VS 2010 - Connecting ComboBox With Enum Kept In Another Class?

Jul 21, 2011

How to connect a combo box and an enum which is kept in another class? I have searched google a lot but the only solutions I can seem to find involve declaring an enum with the combo box. I however want to keep my enum elsewhere, not in the main gui element handling form. The closet thing I could guess was:
Combox99.DataSource = System.Enum.GetValues(GetType(MyBookList.OptionsList)
With MyBookList as a previously defined instance of the BookList class.

View 11 Replies

Intellisense For Enum Types In Visual Studio 2010?

Apr 27, 2011

I am using Visual Studio 2010 Prof. In C# I can create my own Enumerator and use it like this:MyEnum value = Now, Intellisense will suggest a value of MyEnum. In VB, when I write:Dim value As MyEnum = I get a huge list of every types. When starting to write my enumerator value (could be a word like "sunny") it filters out some types but I would like to have it like in C#. Anyway I will use the MyEnum type and no "String nor Objecte nor IntPtr...".

View 2 Replies

VS 2010 Enum Class And Cyclic Correspondence Checking

Mar 13, 2011

I wanted to make a collection of definitions public, for which the Enum class was a perfect candidate, but I also had the need to check variables against all the possibile enum members to see which one they were.

In this scenario my solution was to write a public enum class in which all the members were made available, and replicate the same listing in an array in order to iterate through.

In fact the only way I know to iterate through all memebers is a cycle (either "for each" or "while somecondition" and a moving index). But I guess there must be a simpler way to make use of an enum class.

View 10 Replies

Way To Concatenate List Of Strings Into A Comma-separated Strings, Where Strings Are Members Of An Object?

Oct 16, 2009

Say I have a List(Of Tag) with Tag being an object. One member of Tag, Tag.Description, is a string, and I want to make a comma-separated concatenation of the Description members.Is there an easier way to do this than to read the Description members into a List(Of String) and then use the Join function?

View 2 Replies

Make Sure Strings Contain Only Letters?

Aug 24, 2010

I'm entering data into a text box, and I want to make sure the data I enter contains only letters. Is there any way in Visual Basic that I can go about doing this?

View 7 Replies

Make A Program In VB Which Requires The Use Of 24-bit Strings

Mar 10, 2010

I am trying to make a program in Visual Basic which requires the use of 24-bit strings. However, I am not aware of a common name for them. I know that Byte is 8-bit, and Short is 16-bit, so is there a name for 24-bit?If not, then is there any way to combine a Byte and a Short to create the needed 24-bit value in my program?

View 2 Replies

VS 2008 Make LINQ Strings?

Feb 4, 2010

q1/ how can i convert a lowercase string to sentence case with LINQ, without losing my rtb formatting?

View 2 Replies

Custom Control - Make Properties For Strings Etc?

Mar 16, 2010

I have a custom list control, using labels to display content.How can I add a list property to the control so I can inject items into the custom listbox?I know how to make properties for strings etc. but I can't get it to work to make a list property...

View 1 Replies

(VB 2008) Moving Strings / Cannot Make The Code Work When It Gets To Consonants

Apr 11, 2009

I cannot make the code work when it gets to consonants. I cannot get the consonant part correct.

Code:
'Date of last Modification: 4/11/2009
'Pig Latin Converter: Takes and English words and converts it to Pig Latin
'Rules stated in comments within calButton click event procedure

[code]....

View 3 Replies

VS 2010 : Using Strings In Enums?

Jan 9, 2012

Is there a way to use strings in Enums like the example below:

Enum myEnum
val1 = "some string 1"
val2 = "some string 2"
val3 = "some string etc"
End Enum

It seems like you can only use integers for the underlying values.

View 13 Replies

VS 2010 Get The Text Between Two Strings?

Sep 28, 2011

I guess my question has two parts:

1. My program has to read text out of a text file. I use some HTML tags to preserve the formatting. For example, I might have the line "this is a <b> line </b> of <b> text </b>" where "line" and "text" are bold. How do I make it so the string prints to a RichtextBox, but only "line" and "text" are bold? I would use a RichTextbox.SaveFile method, but the program works by reading a group of richtextboxes in a flowlayoutpanel and appending them to a single text file.

2. How would I extract the text from between two strings? For instance, I have created special tags for use in my program. These tags tell the program where to add controls. Say my string was:

"[IMG= "dog.jpg" /] this is a picture of a dog. [IMG= "cat.jpg"] this is a picture of a cat."

For each occurrence of the string "[IMG=", I would need it to find the corresponding "/]" and extract the text between the two. I could maybe do something with a substring function. I don't know.

View 1 Replies

VS 2010 How To Concatenate Strings

Jul 5, 2011

how do i concatenate strings? i have done it like this.

[Code]...

View 5 Replies

VS 2010 Parsing Strings?

Oct 29, 2011

If INPUT = "Fog/Mist" Or "Overcast Haze" Or "Freezing Fog" Or "Shallow Fog" Or "Partial Fog" Or "Patches of Fog" Or "Fog in Vicinity" Or "Freezing Fog in Vicinity" Or "Shallow Fog in Vicinity" Or "Partial Fog in Vicinity" Or "Patches of Fog in Vicinity" Or "Showers

[code].....

View 14 Replies

VS 2010 Using Strings As Data

May 13, 2011

Forgive me for the total noobness of the question which follows. I am preparing something extremely simple for a project at work. This part involves generation of new names, for stuff like Stone Bridge, Farmer Grove Hunters Meadow. You need a first name and a last name, which would be two sets of strings, say, 20 items each. Last time I wrote VB code, around VB3, I would have written

[Code]....

View 3 Replies

VS 2010 Variable From Two Strings?

Oct 17, 2010

Public Class Form1
Public tc1 = Color.Blue
Public tc2 = Color.Green

[code].....

View 4 Replies

VB 2010 Create List Of Strings?

Oct 23, 2011

I'm new in this forum, and I'm a very very very basic user of the VB. How can I create a list of strings? I'm trying to make a chat with a robot. I put 2 labels. And my code is:

Dim mylist As New List(Of String)
mylist = "hello", "bye"
If Not Label1.Text = mylist Then

[code].....

View 2 Replies







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