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.
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]
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?
[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 .
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
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.
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.
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...".
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.
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?
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?
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...
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.
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
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
That I fill with a list of base words, but I now need to build a new list of words in which will contain a list of every combination of words in the baseList (given that each string is less than the maximum length i specify)For Example if baseList contains
horse at ten football
and the maximum string length is set to 10, the finalList would contain
My goal is actually very simple: I simply want a (shared) function that accepts a List(Of String) which creates an image and writes those strings (line by line) onto the image. There's a bit more to it than that, but for the sake of example this is all you need to know.Usually when drawing on an image I would create a Bitmap object and get the graphics object from Graphics.FromImage:
Dim bmp As New Bitmap(100, 100) Using g As Graphics = Graphics.FromImage(bmp) g.FillRectangle(...)
Seems easy enough, but the problem is that I don't know how many strings there will be in the list, nor how long they will be. The image should 'scale itself' according to the strings in the list. If the list contains 5 strings it should be 5 strings high (plus a little extra for borders). If the list contains only 1 string it should be only one string high. Same goes for the width, if the longest string is 150 pixels, the image needs to be at least 150 pixels (160, 170 or something).
This is all good, I can get the dimensions of the strings by using Graphics.MeasureString. The problem now is that I need the dimensions of the image to create the bitmap. I need the Graphics object to get the dimensions. But, I need the bitmap to get the Graphics object I'm stuck in a loop here, if I don't have the Graphics object (I can't create it from nothing..) then I cannot measure the strings, but if I cannot measure the strings then I cannot determine how large my image will be, so I cannot create a bitmap and associated Graphics object...
This is related to my last question.Even though Access considers Nulls and zero-length strings (ZLS) separate values, often developers wish to treat them as equivalent for the sake of an If...Then statement or some other stretch of code. One way to accomplish this is to write code like this:
' Not so efficient If IsNull(varAge) or varAge = "" Then ' do something
Ok, so say the string is: <a href "[URL]">abc</a> And I just want to get the text "abc" from between the <a href "[URL]"> and the </a>. How would I do so? I dont think I can use the split function, can I?
I want to get a string between 2 strings using Regex.The the string I have is "<b>hello</b>", now I want to get the string between <b> and </b>. I guess its something like Regex(String, "<b>(.+)</b>" but I'm not sure how to do it. I know there is this function called GetBetween but I guess this is a better way.
I'm populating a datagridview from a database where all the data has had apostrophes and quotation marks stripped out and replaced with ASCII values; now I want to replace them back. Since the user can perform a variety of queries that are all displayed in the same table, any column might contain text fields.
This is in a RichTextBox. I'm making a string of sports stats and I need to have them aligned neatly in the RichTextBox. Here is an example: str = "12/24 (tab) 225 yards (tab) 2 TDs (tab) 2 INTs" When I use the vbTab constant in place of (tab) I run into problems as the size of the text in each column can be different which makes the tab not balance out correctly.