Add Enum Entries During Runtime?
Jun 27, 2010Is it possible to add Enum entries during runtime?
View 7 RepliesIs it possible to add Enum entries during runtime?
View 7 RepliesI 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"
I have a program where you have three entries, CD name, artist, price and it goes into a listbox and .txt file when closing. I have to have a message box if you enter the same CD name. I have a code to open the .txt file and compare strings but I need to change it to compare only the CD name and not all three entries. Is there a way to do my string compare against my listbox without opening the .txt file?? The program loads the listbox from the .txt file when opening. Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click' adds CD information to the list box
' declare variables
Dim strName As String
Dim strArtist As String
Dim strPrice As String
[code].....
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 RepliesI want to set a certain column to true or false automatically based on what value another column has entered. I managed to get this working by myself using the 'SQL Pane' in VB and testing it by using execute sql but I don't know what to do now. I assumed that I could just save it and it would work from there but that's not the case, it dissapears from the SQL Pane if I close the project (even though it worked fine when I ran the project the first time), so where do I put it/what do I do with it in order to get this to work?
View 1 RepliesRE - 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
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 RepliesI'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
I have created multiple dropdown list at runtime and populated with data. I also have added an eventhandler to determine the selected value of the drop down list.
The code is as follows :
Dim tbl As New Table()
tbl.EnableViewState = "true"
[code].....
I have a Visual Basic 2005 program which runs fine if I execute the built Executable. However if I start the application in VS2005 debugger it gives a weird error
[Code]...
How does enum work in .NET ?
eg.
Enum eOpenMode
Add = 1
Edit = 2
End Enum
[Code].....
How does this gets compared by their value(1,2) or by its name (add,edit) and what will be memory allocation scheme ?
I need to use IN in an EMUN.
-Public enum Talkers
-IN
-GP
-WI
-End Enum
I have an app that I'm calling up a 3rd party API.. and on each call I want to store off the patient data in to logs that are like weekly.. so on each call to the API I want to encrypt the data and push as a line into a file..I kinda dont want to open the file.. add in data then encrypt the whole file, that seems like extra work to me.so if I want to encypt the data from string to byte whats the best way to push into a file and then read out.. should I set the string to be a certain lenght so my writes and reads match up ? or is there a way to write to a data file so that it knows the end of the entry ? should I use a type class for this ?
View 1 Repliesi am using following code to search my computer for files with certian extensions. I currenty searching for .eml files. I need to enter 10 most current files' path to my list box. How can I do it?
Dim DriveLetter As String = "c:"
Dim Ext As String = ".eml"
[code]....
Can an Interface contain an Enum?I am using asp.net 2.0. Suddenly my code started having problems when I added an enum to the interface below. In it, LookUpType is an enum.
Public Interface ILookup
Property ID() As Int32
Property Text() As String
[code]....
I'm finding this in some legacy code and just curious what the brackets are for?
Public Enum myEnum
none = 0
abc = 2
[code]....
More for interest than actual need.is it possible to have an automatically decreasing enum in C# or VB.NET?
public enum testEnum
{
this = -1,
that,
other,
}
So that that = -2 and other = -3.I'm pretty sure the only way to do it is to specifically assign "that" and "other", but I wondered if there was an automatic way of doing it.
Edit To be clear, I'm simply talking about the automatic assignment of the value, not the actual value of the enum decreasing.
I'm using vb but still learning it. Here is the question, I have following ENUM created so that i can use it all the form. I created this Enum on my main form (startup form) and want to use in another form.
Enum MyStatus
Good = 1
Bad = 2
Normal = 3
End Enum
Now from other form I'm using it like frmMainmenu.MyStatus.red. I was wondering how i can make it public or create it in a way so that i don't need to give the prefix frmmainmenu before using its value.
I have an enum like this:
Public Enum AssociateType
ALL
TIMED
COMMISSIONED
MANAGER
INVALID
End Enum
and I want to get a string based on the value of this enum:
Public Shared Function TypeToString(ByVal Type As AssociateType) As String
'Inputs: An AssociateType of the type of associate.
'Outputs: A string of the type of associate.
[Code]......
How do I do this C# statement in VB.Net (2005):MainMap.MapType =(MapType)comboBoxMapType.SelectedValue;MainMap only accepts Types so passing the Integer value of the type is not possible. The combo contains a list of strings:comboBoxMapType.DataSource = Enum.GetValues(typeof(MapType));In my case I need to limit the list to less than 100% of the Enum values so code similar to .Datasource= code will not work.So in general I need a way to return an enum given the name of the enum.Maybe I should just do a Collection of Enums (if that is even possible) and use the name as the Key?
View 2 RepliesI have a DataType (text, numeric, date, boolean, money) enum and I need to put that in a file. How should I call the file and where in my DataAccessLayer.Generic namespace should I put the file into? Right now the file is called enum.vb and is in theDataAccessLayer.Generic.DataTypes namespace. The Result is ataAccessLayer.Generic.DataTypes.DataType, but it is misleading because the file is called enum.vb
View 2 RepliesI'm finding this in some legacy code and just curious what the brackets are for?
Public Enum myEnum
none = 0
abc = 2
[code].....
In vb.net, I got an Enum defined As Integer:
Enum enUtilityTypeDetailStudentEntryWorkflow As Integer
enUTDSEW_Default = 379
[code].....
This works but it adds a lot of noise to the code and it seems like the Enum is already defined as an Integer, making me think, why do I have to assign it again?
i have a list as an enum and when I want to select values as following, what is the best way to approach it
Public Enum ScanLocations
station1 = 1
station2 = 2
station3 = 3
station4 = 4
end enum
So if i have "station2" as a value in a textbox etc, and I click a button 'next' then it will give me "station3"if i click 'previous' then it will give me "station1"
I've made a program for a small business that keeps track of what items there are, their prices, and the quantities of those items. I would like to add a button that goes along the lines of "Add to sale" or "Add to cart", and have it select the currently highlighted item in the database grid view to add the price column up, to make a total for a sale.
[Code]...
I have lines like this in my text file
SP-J1-B 203101 Black 99.0 28 0 0
SP-J2-B 203102 Black 99.0 28 0 0
SP-J3-B 20303 Black 99.0 28 0 0
SP-J4-B 20377 Black 99.0 28 0 0
SP-J5-B 203104 Black 99.0 28 0 0
i want to change the value of column two with my own value so i split the string like this
Dim FileContents() As String = IO.File.ReadAllLines("C:\switchoutputA.txt")
For Y As Integer = 0 To FileContents.GetUpperBound(0)
Dim blah() As String = FileContents(Y).Split(New String() {" "},
[Code]....
but some times it dont want to remove empty entries and i get blah(1)="" without any value. how to remove the empty entries?
I have form on VB2008 and Mysql as Database which have 24 textfields on a form.I want to impose certain condition that when ever user adds/updates/modifies data into database for example You may have entered text in a numeric fied or a number that is larger than the fieldsize setting permitts. if violates message box should appear with Invalid entries
View 5 RepliesI'm trying to create a Treeview that will have around 400 entries and thought I'd import the names from a text file that i'll create from my spreadsheet.
In my following code I'm just using 1 line of text from the text file. The line contains Parent/child level1/child level2/child level3/child level3.text
e.g. -Weapons
|
|-Axe
| |
[Code].....
I'm using the MS example script [URL] to install a COM+ application. For uninstall I have a script that shuts down the app, calls Remove from the Catelog App Collection, and then I call regsvr32 /u. This cleans up the COM entries and removes my app from the catelog but leaves behind the CoClass and Interfaces in HKEY_LOCALSoftwareMicrosoftCom3Selfreg. How should the script remove the SelfReg values?
objCatalog.ShutdownApplication(myAppName)
objApplicationsColl.Remove(iCounter)
objApplicationsColl.SaveChanges()
[code]....
well with studing i think i can add data to the xml to save it to the forum but i think the problem is when deteleting stuff from the xml file is the error
View 1 Replies