|
Why is it a serious problem? A form is just a class, and it's common practice to create and pass values to custom constructors, correct?
Andrew
|
|
|
|
|
A form is a class, but once instanciate it is an object that ocupies memory space. The bigger the object, the bigger the cost of passing it through constructors. Yes, if you pass it by reference instead you eliminate some of that cost because the CLR does not create a copy of the object. But it is better practice to pass smaller objects through constructors.
|
|
|
|
|
Thank you for the explanation. What you're saying makes absolute sense. Your help is much appreciated.
Thanks again,
Andrew
P.S What is a better way to pass data between mdiChild forms?
|
|
|
|
|
I can't for the life of me work out (or find samples on) how to read back the attribute of an entry in an Enum, for example:
Public Enum Colours<br />
<Description="Bright Red"> BrightRed = 0<br />
<Description="Brilliant Yellow"> BrightYellow = 1<br />
<Description="Puce"> Horrible = 2<br />
End Enum
I know it has something to do with Reflection, but that doesnt seem to help
Ultimately I want to write a function to able to do something like GetDescription(GetType(Colours))
Thanks, ro.
|
|
|
|
|
you mean something like this :
VB:
<font color="blue">Public</font> <font color="blue">Enum</font> Colours
BrightRed = 0
BrightYellow = 1
Horrible = 2
<font color="blue">End</font> <font color="blue">Enum</font>
<font color="blue">Private</font> <font color="blue">Sub</font> Button1_Click(<font color="blue">ByVal</font> sender <font color="blue">As</font> System.Object, <font color="blue">ByVal</font> e <font color="blue">As</font> System.EventArgs) <font color="blue">Handles</font> Button1.Click
<font color="blue">Dim</font> c <font color="blue">As</font> Colours
MessageBox.Show(GetColours(c.BrightRed))
<font color="blue">End</font> <font color="blue">Sub</font>
<font color="blue">Public</font> <font color="blue">Function</font> GetColours(<font color="blue">ByVal</font> i <font color="blue">As Integer</font>) <font color="blue">As String</font>
<font color="blue">Dim</font> clr <font color="blue">As</font> Colours
<font color="blue">Select Case</font> i <font color="darkgreen">'/// numerical value of the colour.</font>
<font color="blue">Case</font> clr.BrightRed
<font color="blue">Return</font> "you chose BrightRed" <font color="darkgreen">' <font color="blue">Case</font> clr.BrightYellow
<font color="blue">Return</font> "you chose BrightYellow"
<font color="blue">Case</font> clr.Horrible
<font color="blue">Return</font> "you chose Horrible"
<font color="blue">End Select</font>
<font color="blue">End</font> <font color="blue">Function</font>
hope that helps a little
<font color="blue">Private void</font> ExpectingTwins(<font color="blue">string</font> twins)
{
<font color="blue">switch</font>(twins)
{
<font color="blue">Case</font> ("twins on the way"):
MessageBox.Show("for mr and mrs dynamic","twins on the way");
<font color="blue">break</font>;
}
}
|
|
|
|
|
The following function should work for you ...
Imports System.ComponentModel<br />
Imports System.Reflection<br />
<br />
Private Function GetContentTypeValue(ByVal value As Colours) As String<br />
Dim fi As FieldInfo = value.GetType.GetField(value.ToString)<br />
Dim attributes As DescriptionAttribute() = CType(fi.GetCustomAttributes(GetType(DescriptionAttribute), False), DescriptionAttribute())<br />
If attributes.Length > 0 Then<br />
Return attributes(0).Value<br />
Else<br />
Return String.Empty<br />
End If<br />
End Function
|
|
|
|
|
I have the following code in a vb script to open the cd-rom drives:
Set oWMP = CreateObject("WMPlayer.OCX.7" )
Set colCDROMs = oWMP.cdromCollection
if colCDROMs.Count >= 1 then
For i = 0 to colCDROMs.Count - 1
colCDROMs.Item(i).Eject
Next ' cdrom
End If
But, how do I close the cd-rom drive?
|
|
|
|
|
|
Hi,
I am developing a Visual Basic Project that takes a lot of data from a DB and generates an Excel Chart. Then, I have to save the chart in HTML format, because the chart is viewed in a web page. I have to put a background color accordying to the web site style. But Excel don't accept the background color that I need to fix. It seems that color palette in Excel is limited to few colors. I tried also with a background picture, but it covers only the chart area, and the HTML generated code creates an image for the chart and the body background color remains white...
Anybody knows how can I resolve this problem?
Thanks in advance,
LAURA
|
|
|
|
|
OK, i have this mp3 renaming tool written in VB and I've added a context menu item for mp3 files called "MP3Rename". When I right click on an mp3 file and choose MP3Rename from the context menu, it runs my program in the background to rename the mp3 file. This worls perfectly when I select one file, but if I select multiple files, my program doesn't even get executed. I know this because I've placed a MsgBox statement on the first line of my code, but the message box never appears with multiple files (it does with a single file). Anyone have any ideas why selecting multiple files does absolutely nothing? Thanks.
|
|
|
|
|
Hi all,
I have a problem. I have 1 exe and several dll's. From my exe (mostly an MDI form) I call to the different dll's which contain mainly forms. When I want to close such a form, what's the best method 'Close()' or 'Dispose()'. You see, I want to be sure that the complete dll is removed from memory each time, since it is called by 'objAssembly.CreateInstance'...
Greetings,
Sigurd
|
|
|
|
|
Someone correct me if I'm wrong here:
If you didn't explicitly call the Win32 API function LoadLibrary(), you can't unload it.
DLL load and unload is handled automatically by the runtime (in both VB and VB.NET.) When your App loads, the runtime attempts to resolve all external references and loads the appropriate DLL's automatically. Then your app is able to call the functions you wanted. When you're done using the resources of the DLL, it WILL NOT unload. This won't happen (automatically, anyway) until your Application quits because that's when your releasing your references to the DLL.
RageInTheMachine9532
|
|
|
|
|
I am developing an application and i have lot of forms and i would like to keep these following features for simple text data(included in Textbox).
Undo
cut
Copy
Paste
Is there any method to generalize the situation.
Thank you in Advance.
John Joseph
Programmer in VB, VC
|
|
|
|
|
I'am looking for a away to enable CutCopyMode, run a Macro and then disable
CutCopyMode when I click on a button.
|
|
|
|
|
How do I get the users login name and pull it into VB?
THanks in advance for your help
|
|
|
|
|
you mean this :
VB:
<font color="blue">Private</font> <font color="blue">Sub</font> Button1_Click(<font color="blue">ByVal</font> sender <font color="blue">As</font> System.Object, <font color="blue">ByVal</font> e <font color="blue">As</font> System.EventArgs) <font color="blue">Handles</font> Button1.Click
<font color="blue">Dim</font> id <font color="blue">As String</font> = System.Environment.UserName & Chr(10) & System.Environment.UserDomainName
MessageBox.Show(id)
<font color="blue">End</font> <font color="blue">Sub</font>
hope that helps, you can also do this :
Imports System.Security.Principal <<< at top of form , then this :
VB:
<font color="blue">Private</font> <font color="blue">Sub</font> Button3_Click(<font color="blue">ByVal</font> sender <font color="blue">As</font> System.Object, <font color="blue">ByVal</font> e <font color="blue">As</font> System.EventArgs) <font color="blue">Handles</font> Button3.Click
<font color="blue">Dim</font> wp <font color="blue">As</font> WindowsPrincipal
wp = <font color="blue">New</font> WindowsPrincipal(WindowsIdentity.GetCurrent())
MsgBox(wp.Identity.Name.ToString)
<font color="blue">End</font> <font color="blue">Sub</font>
<font color="blue">Private void</font> ExpectingTwins(<font color="blue">string</font> twins)
{
<font color="blue">switch</font>(twins)
{
<font color="blue">Case</font> ("twins on the way"):
MessageBox.Show("for mr and mrs dynamic","twins on the way");
<font color="blue">break</font>;
}
}
|
|
|
|
|
thanks..thats exactly what i needed
|
|
|
|
|
Hi,
I've noticed a small problem (for me) with the MonthCalendar control.
My app grabs info from a database when the selected date is changed. To
make a long story short, I want to use the DateChanged event. This is fine,
but it fires exactly every 2 minutes by itself.
I've tested it with timestamps.
While I can get around this with a boolean flag controlled by user inputs,
I can't find any info on this 'feature' anywhere.
Has anyone else come across this? I'd be interested to know the background
to it if anyone knows.
Thanks!
J
|
|
|
|
|
hi, i have been merging 2 projects written independently. Now i want to create global variable, which could be called by both projects. Any hint on how I can do that? Thankx
|
|
|
|
|
dear all
how to make a activex exe component which returns immediately after its function is called from a client.
any samples or source code will be appreciated.
regards
rIsHaBH
|
|
|
|
|
Hello
What do you wnat to return after the function call..
Do you want to raise any events or something like that.
regards
Computer City
Programmer in VB, VC
|
|
|
|
|
dear all
how to make a activex exe component which returns immediately after its function is called from a client.
any samples or source code will be appreciated.
regards
rIsHaBH
|
|
|
|
|
i'm trying to create an XML web service. I have done the following:
1) install & setup IIS
2) create ASP.NET web service in VB (called "HelloWorldService")
3) uncommented the HelloWorld web method in HelloWorldService.asmx
4) compiled the project
5) created a new VB.NET windows app (HelloWorldClient)
6) tried to add a web reference to http://localhost/HelloWorldService/HelloWorldService.vsdisco
i got the following errors:
Errors
The document at the url http://localhost/HelloWorldService/HelloWorldService.vsdisco was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'WSDL Document' is 'There is an error in XML document (2, 2).'.
- <dynamicdiscovery xmlns="urn:schemas-dynamicdiscovery:disco.2000-03-17"> was not expected.
- Report from 'DISCO Document' is 'Discovery document at the URL http://localhost/HelloWorldService/HelloWorldService.vsdisco could not be found.'.
- The document format is not recognized.
- Report from 'XML Schema' is 'Expected Schema root. Make sure that the root element is <schema> and the namespace is 'http://www.w3.org/2001/XMLSchema' for an XSD schema or 'urn:schemas-microsoft-com:xml-data' for an XDR schema. An error occurred at (2, 2).'.
----------
is there soemthing i forgot to do? if u can point me in the right direction, it'd be much appreciated
oh, and i'm running windows XP pro sp2 with IIS.
|
|
|
|
|
Don't use the .vsdisco, use the .asmx as your web reference.
IIRC the .vsdisco stuff is deprecated anyway.
--
Ian Darling
|
|
|
|
|
Thanks, I actually tried that and it gave me an option to save or open the file. I figured out why it wasn't working. I forgot to install some web components from the VS.NET install cd. Go figure.
Thanks
|
|
|
|