|
There is an excelent article by Marc Clifton that I think would be of great help to you:
Article[^]
|
|
|
|
|
How can you dynamically load values in an enum statement rather than hard code them line by line as seen in the below example code. I want to be able to load an enum statement from data I query from a database.
Typical hard coded enum
Public Enum compas_dir
North = 0
South = 1
East = 2
West = 3
End Enum
|
|
|
|
|
I think Enums have to be set at compile time. If I am right, you might want to try a different data structure, such as a collection[^], that you can manipulate at run-time. If I'm not, perhaps someone will let me know.
|
|
|
|
|
Apparently, you, Chas or someone didn't like this answer and 1-voted it. However, in its essentials, it is correct. You cannot change the values of an Enum after the application has been compiled. If you could, it would defeat the purpose of Enums.
A dictionary-type object would be a good choice for storing the kind of pair values you're probably thinking about. I'd use a hash-table, but I've been told I overuse 'em.
Jon
Smith & Wesson: The original point and click interface
|
|
|
|
|
Thanks for confirming that for me, Oakman. I'll assume they 1-voted it because it wasn't the answer they were looking for, and not because it was a bad answer, even though I really don't care.
|
|
|
|
|
If memory serves me correctly, which it does with declining ability, enums are compiled to classes extending .. suprisingly .. system.Enum. The enum members become static fields.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
I am trying to use a C# example of a usercontrol to write a VB.Net usercontrol with some simular features. My first step was to convert a C# control to VB.Net. I love this example (a newly written wizard control) and am trying to design a multi-pane control based using this control as an example of the right way to do things. However... I am not understanding the following code...
public delegate void ItemChangingHandler(int index, GenericChangeEventArgs<t> e);
public event ItemChangingHandler Changing;
protected override void OnSet(int index, object oldValue, object newValue)
{
GenericChangeEventArgs<T> e = new GenericChangeEventArgs<T>((T)oldValue, (T)newValue);
if (Changing != null)
{
Changing(index, e);
if (e.Cancel)
{
return;
}
}
base.OnSet(index, oldValue, newValue);
}
What does If (Changing != null) really do. If I translate this to VB.Net I get
Protected Overloads Overrides Sub OnSet(ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object)
Dim e As New GenericChangeEventArgs(Of T)(DirectCast(oldValue, T), DirectCast(newValue, T))
If Changing IsNot Nothing Then
RaiseEvent Changing(index, e)
If e.Cancel Then Exit Sub
End If
MyBase.OnSet(index, oldValue, newValue)
End Sub ' (ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object)
Where the line "If Changing IsNot Nothing Then" generates a compiler error...
Error 1 'Public Event Changing(index As Integer, e As GenericChangeEventArgs(Of T))' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event. C:\My Projects\VB.Net\etc\ezWizard\ezWizard\Collection\GenericCollection.vb 347 10 ezWizard
I would greatly appriciate any help anyone could give me. Anyone understand C# and VB.Net?
Keith Alan Yerian
Keith Alan Yerian
|
|
|
|
|
1. You don't need to do this sort of check for VB. VB does this behind the scenes when you use RaiseEvent.
2. If you really need it, then "If ChangingEvent IsNot Nothing" works. Note the 'Event' tagged on the end of the event name. This refers to a private hidden variable that VB creates for your events.
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
VB & C# to Java Converter
Java to VB & C# Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB, C#, or Java to C++/CLI
|
|
|
|
|
In C# if the form, class, or whatever that instantiated the object with the 'Changing' event did not define that event, then Changing will have a value of null, and raising the event would actually generate an exception. I don't think VB.Net needs to do any such similar check. I believe if VB.Net raises an event that the calling object has not accounted for, nothing happens and no exception is raised.
|
|
|
|
|
Hi ,
how to merge cells of table control i have usded cells colspan property but not able to merge because i have to merge cells form certain nymber to certain number .
for example from 4 to 8 cells i have to merge other remians same
any hint or article is highly apperciated
Regards
Thanks in advance
|
|
|
|
|
|
hi .. guys
I have a problem in my code. this problem apears
when I send a text message from the client side to
the server side, the server recieves full bytes completely
you can check the code below :-
Dim bytes(tcpClient.ReceiveBufferSize) As Byte<br />
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))<br />
clientdata = Encoding.UTF8.GetString(bytes)<br />
msg = q.Dequeue()<br />
'While (check)<br />
'Dim s1 As String = msg.getIP()<br />
'Dim s2 As String = clientdata.Length<br />
'If s1 = s2 Then<br />
' Dim s3 As Boolean = True<br />
'End If<br />
If clientdata = msg.getIP() Then<br />
sendBytes = Encoding.UTF8.GetBytes(clientdata)<br />
networkStream.Write(sendBytes, 0, sendBytes.Length)<br />
check = False<br />
Else<br />
q.Enqueue(msg)<br />
MessageBox.Show("you are here")<br />
End If
|
|
|
|
|
I think its right
Please try and explain an little more clearly.
abuamd wrote: when I send a text message from the client side to
the server side, the server recieves full bytes completely
I would expect it to, thats the idea isn't it?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
ashfield .. when I send ! for examle ::
I want to send this string ("hello") to the server by newtwork
stream. this string will take 8192 byte (i.e. I want the stream
to serve only the size(length) of this string as I exampled)
thanks
|
|
|
|
|
|
hi ..
you can see the explaining above post.
thanks to help me
|
|
|
|
|
Can i publish a public property in Web service like webmethod()
|
|
|
|
|
Think about what you asked and how the web service works.
webmethod - receives and returns information
service - remote from your client
So if you are going to attempt to use the objects (service) property the way you do a winforms it ain't going to work.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello Friends,
I have developed one small software in vb.net.
I want to add one feature, Updating like antivirus software. how to add this feature in my software please help me.
Thanks in advnace.
Adarsh
|
|
|
|
|
Google for Click once Deployment.
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Thanks for your reply
But I don't want to publish.
But I am asking, Update feature to add in my application.
Adarsh
|
|
|
|
|
|
Thanks for your reply.
I will check given application.
Adarsh
|
|
|
|
|
I need the code to display barcode generation dynamically in label box using VB.Net
|
|
|
|
|
mutharasi wrote: I need the code to display barcode generation dynamically in label box using VB.Net
Ever heard of manners?
Write some code, then when it doesn't work post it here and MAYBE someone will try and help you - if you ask nicely.
Bob
Ashfield Consultants Ltd
|
|
|
|