Add An Enum To An Existing .NET Structure, Like Date?
Feb 23, 2011
What I am wondering is, is it possible to create an enum and attach it to the DateTime structure? Extension Methods come instantly to mind, but I don't know of a way to pull this off using them.
Dim july As DateTime.Months = DateTime.Months.July
Public Enum Months
January = 1
[code]....
View 3 Replies
ADVERTISEMENT
Oct 26, 2011
So apparently Microsoft does not have a Months Enum on their Date structure.What I am wondering is, is it possible to create an enum and attach it to the DateTime structure? Extension Methods come instantly to mind, but I don't know of a way to pull this off using them.[code]...
View 3 Replies
Feb 4, 2009
I am coding in vb.net. I want to achieve something like this (sample) -
Structure Transport
Dim land as L
Dim Air as A
[CODE]...
But though i can create enum but how can I embedd it in structure. It is not allowing me to do that.
View 2 Replies
Nov 10, 2011
I think it's substituable for just Dim, Public or others. What is merit by using structure, property ??
View 1 Replies
May 19, 2009
I have an enum that I want to give some methods. I thought about changing the enum to a structure so I could add properties, but then the enum is a value inside the structure (not the structure itself), so this would affect comparisons and such. (For example, instead of writing
EnumVariable=EnumConstant,
Now it is
StructureVariable.EnumValue=EnumConstant).
At least, this is my understanding of it. It seems awkward to have to do this for such a simple scenario, so is it possible give enums properties, yet still have them treated as before? I've thought maybe I need to create a new valuetype from scratch, but I've never done that before.
View 7 Replies
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
Oct 31, 2011
I've been searching for a while now and can't find a way to add a constructor to the Rectangle Structure.
Is this even possible without inheriting from the class?
View 2 Replies
Feb 21, 2011
I'm fairly new to ASP.NET & VB.I've been asked to take an existing textbox that is automatically filled with the current date and allow the user to either add a "+" or "-" and a number or a spcific number and convert that into a date.I underdstand the basic concept on how to do this, but I'm running into some problems using the proper commands in order for this to work.The Textbox is called txtDate.What I've tried to do is this:
If txtDate = '+' Or '-' Then
DateAdd("d", txtDate, today)
End If
Here is what the whole thing looks like:
Protected
Sub
DateEnter_Click(ByVal
sender As[code].....
View 1 Replies
May 1, 2009
how to write the code for my project.I am to base my new project on an existing one(existing one has code that works 100%)and create an Array of a structure that bascially holds the information from a summary form AND the totals from an AddToOrder_Click event. If you are still with me)... I cant figure out what the code is for my structure and Array so that I STILL have a Summary Form but I have an array that shows when I click my PrintPreview. So an Array is basically a "space" that holds information, like my summary form except it doesnt show until I click PrintPreview right?
If I just wanted to show the table then my code belongs in the PrintDocument1_PrintPage to show the array but the actual structure code belongs in the Click_Event of my AddToOrder? Please Please understand I AM NOT asking for anyone to write my code, basically I am asking for some clarification on what exactly creating an array from a structure is and therefore determing where the structure is to be placed in my code..
View 6 Replies
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
Jun 30, 2009
I am creating a program that takes into account pay from a job. I will try to describe the problem I am having using some psuedo code - so dont take syntax too seriously.
I created a structure that has some of the following values:
Name as String
Amount as Double
FrequencyType as MyEnumerator
MyEnumerator looks like this:
EveryTwoWeeks = 1
TwiceAMonth = 2
Weekly = 3
Now my problem is how do I add the date ranges into my structure?If your pay is weekly or twice a week, then I just need a single date because all other paydays should increment in 1 or 2 week blocks. But if the pay is twice a month I need two dates. It seems like there has got to be a better way then just having two dates in my structure and knowing that you just need the 2nd date if the FrequencyType is = 2 (TwiceAMonth).I was thinking that instead of a Structure I should use a class and then I could create a function that returns the date or dates depending on the enumeration type that you pass into it.What would be the "correct" way of doing this? I think I need a type of enumerator that allows for more then just integer type values.
[code]...
View 2 Replies
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
Sep 30, 2009
Does anyone have some code that will easily convert this C++ _DATE_TIME date/time structure to a VB.NET date value ?
[Code]...
View 10 Replies
May 28, 2012
I understand how to rename a file in vb.net as I use the coding at the end of my post. However, is its possible to rename a file and if the file exists then to rename it and add +1 to the file name? So if I ran the code.
'Run it first time
My.Computer.FileSystem.RenameFile("c: est est.txt", "c: estNewName.txt")
'Run it again but it should add +1 as the file will already exists so it should be "c: estNewName1.txt"
My.Computer.FileSystem.RenameFile("c: est est.txt", "c: estNewName.txt")
Decided rather than rename and +1 it would be better to just date stamp it.
My.Computer.FileSystem.RenameFile("c: est est.txt", "Test" & Format(Date.Now, "ddMMyy") & ".txt")
View 2 Replies
Feb 18, 2010
I'm using Visual Studio .Net 2008 on Vista. The goal of my program is to watch a directory, get file information, then sort them by thier date, and produce a updated text file. I can't seem to get my code to generate a list of files sorted by date. The code does produce a general list of files, however presently ordered in the directory. I also tried an alternate way of sorting the files by date by creating a string, removing the date using substring, then comparing the file dates using datetime.parse but it produces a exception error.[code]...
View 5 Replies
Dec 27, 2010
I am trying to convert text in a text box (txtEventDate.Text) to a date type in a structure: ThisEvent.EventDate (declared as date). The text in the textbox is of the form: 05/18/1927 (i.e. May 18th, 1927) and after looking long and hard thru the forums attempting several different things, like:
'ThisEvent.EventDate = CDate(Format("#" & txtEventDate.Text & "#", "mm/dd/yyyy"))
'ThisEvent.EventDate = Date.Parse(txtEventDate.Text & "12:01:00 AM")
'Date.TryParse(txtEventDate.Text, ThisEvent.EventDate)
The code is commented out because none of them convert the string to a date value (I know a date does not have a format and I have looked thru the MSDN). How can I stay logged and composing a thread past some arbitrary time limit that forces a re-login?
View 2 Replies
Oct 22, 2011
I want to insert existing tables in new table stock by selecting from date and to date ..I tried this
cmd = New SqlCommand("INSERT INTO Stock (OpeningStockdate,Productcode,Openingstock,Despatch,Receipt,ClosingStock) (SELECT A.OpeningStockdate as OpeningStockdate, A.PC as Productcode,MAX(A.Openstock) AS Openingstock ,SUM(C.Qty) AS Despatch,SUM(B.Qty)
AS Receipt,MAX(Openstock) + ISNULL(SUM(B.Qty),0) -ISNULL(SUM(C.Qty),0) AS ClosingStock FROM Product A LEFT JOIN Receipt B ON
[code]....
i got this error" Incorrect syntax near the keyword 'Where' "
View 7 Replies
Jun 7, 2011
Is there a framework class that converts the partial day strings on these forums to a DateTime? Examples are "a few seconds ago", "19 minutes ago" and 3" hours 26 minutes ago",
View 4 Replies
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
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
Jul 17, 2009
I want to format now() to this structure.. "mdyy"
month with no leading 0 if < 10
day with no leading 0 if < 10
View 4 Replies
Nov 11, 2010
I need to make a program in vb that takes a 1 page existing pdf that i specify and inserts that into another existing pdf that i specify.
View 4 Replies
Jan 5, 2012
Module Module1
Public Structure structure1
Public TRANS() As structure2
End Structure
Public Structure structure2
Public X() As Integer
End Structure
End Module
View 17 Replies
Jan 5, 2010
I'm new to VB 2008 after having spent a long time with VB6, so I apologize if this is a stupid question. But I'd really like to have this straightened out.
Let's say I have a pretty large structure that has lots of properties.
Code:
Now say that I want an internal database with about 10 instances of this structure total, describing, say, 10 different products that a store sells. When these values are loaded from a database, they remain totally static. (However, they can be different each time a program loads)
Now say that I have a class. Each instance of this class is a type of that BaseProduct structure. Meaning, each instance of the class pertains to one of the 10 types of products that the store sells. However, this class has additional properties that pertain specifically to each instance, which are not static.
Code:
Now, the problem here is... If I have 200 different transactions, each one contains an instance of BaseProduct. BaseProduct is HUGE, and is largely redundant (only 10 types possible), so I think it's a little silly to include a whole copy of it with EVERY transaction. However, the Transaction class really needs information regarding the base product it pertains to. Is there a way to, instead of declaring a New BaseProduct in the Transaction class, to simply make one of the properties of the Transaction class a pointer to a BaseProduct variable?
In VB6, I would accomplish this by making a BaseProduct(10) array, and then giving each Transaction an ID number referring to an entry in that array. But in VB 2008, using class structure, this is impossible. I can't define the BaseProduct(10) array outside of a class in a namespace, and if I define it in the actual application's form, then the class loses modularity since it relies on the application that's using it.
View 11 Replies
Aug 29, 2009
I am trying to communicate with an external device and i am trying to send a byte array to the external device via sockets but i am always getting a response the message size is too small so i am not sure what i have done wrong. Between the data type there should be no alignment present and all numbers are represented in little endian format. The char array is not null terminated as mentioned in the protocol specifications.
I have to send data based on a struct that embeds 2 other struct. So here's my vb.net code for the struct used to convert to byte array and the sending part.
Public Structure MESSAGETYPE_OIP_Login
Dim Header() As COMMANDHEADER
Dim UserName() As PSTRING
[Code]....
View 2 Replies
Apr 14, 2012
I'm experiencing a problem with the following c-structure:
typedef struct tagTEXTUREPROP
{
DWORD dwSize;
[Code].....
The Marshal.SizeOf obviously calculates a size of 76 and it works with the DLL function, but it leaves me with some bad feelings.
View 1 Replies
Apr 25, 2010
I'm having a problem that's driving me crazy; I can't understand how to convert the XML structure into a class structure (that I want to use to hydrate a XML document).
The XML document looks like this:
xml
<?xml version="1.0" encoding="utf-8"?>
<artists xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.spotify.com/ns/music/1">
[code]....
View 2 Replies
May 23, 2010
I want to make a structure within a structure. Basically it will appear like this:
Structure ID
dim CardType as string
im CardCode as string
[code]......
View 13 Replies
Oct 12, 2010
In Vb.net I am trying to assign an array of structure to another array of same structure[code]...
View 2 Replies
Apr 8, 2010
Title pretty much says it all. How do I format the date of a dateandtimepicker to insert it into the SQL date datatype?
View 20 Replies