|
Contrary to popular belief, automaticall memory management in .Net is not equivalent to 100% total resource clean up. Coders still have the responsability of freeing some resources through the Dispose() method.
Use dispose whenever available if you want to reduce memory footprint and avoid thoses cases where Net programs' memory usage continuously grows over time. (A five form program should never reach 75 Mb (unless it deals with very large quantities of data like uncompressed 20MB+ images) if coding practices are good.
Also, try minimizing the form in your example and see how much memory it is using (much less). This happens because at startup your program is assigned a large working set to account for any initialization the CLR and associated dlls might need.
|
|
|
|
|
i made an audio program
But i need a function that tells me if the current audio contains music ..
that to provide my application more features
Really i need ur help
thanks alot
ahmed elmahdy
|
|
|
|
|
elmahdy wrote:
But i need a function that tells me if the current audio contains music
What sort of audio are you using? mp3, wav, wma?
Then is there any meta-data associated with that format to indicate if it's music or something else (eg, audiobook or sample)
AFAIK there's no simple way to tell if something is music or not (I'm guessing some sort of analysis to detect repeating beats?) - and writing software that does this requires musical expertise and usually costs $£€
--
Ian Darling
|
|
|
|
|
i use wav sort
i want to display a sweety things when my program find music ... i will deal with sound ports ??
what is the best method ?
thanks alot
ahmed elmahdy
|
|
|
|
|
elmahdy wrote:
what is the best method ?
I don't know. The scope of your question is outside what this forum is aimed at, and I'm not a music expert. Try searching on google?
--
Ian Darling
|
|
|
|
|
How can I get txtbox1.Text and txtbox2.Text data into the same array, without hand-coding the values into a separate arra y???
|
|
|
|
|
(VB.NET) Try a Datagrid and using data binding on the array instead if you have a lot of textboxes?
(VB6) Use a control array, and then you can use a loop to copy across to the array.
YMMV
--
Ian Darling
|
|
|
|
|
I have 12 textboxes that I need as one array,12 others as a separate array.
I think the datagrid might work, but I've never used that control. Can you point me to an article (beginner level).
Thanks for your help!
|
|
|
|
|
Well, there's probably an article on CP somewhere, but it's really simple - bung a datagrid on your form, then call SetDataBinding on it with your array:
' Example - display an array of 3 items in a datagrid
Dim myArray as String(3) = { "Hi", "Hello", "Bonjour" }
' Haven't tested this, but should work ok
DataGrid1.SetDataBinding(myArray, "")
If you need something more complicated (eg, multiple columns), use a DataTable instead of an Array. All of this is documented in MSDN anyway.
--
Ian Darling
|
|
|
|
|
This is my first time here, so: hi guys! Hope your day does not suck. Mine is OK, but I'm banging my fragile head against a problem with converting UNIX standard epoch numbers to something fairly regular, date-wise.
I receive a timecode from a Perl program, written as seconds since 1970, the standard way of talking about time in the UNIX world. Then my VB component wants to log this thing, and well, I'd like to be able to record it like YYYY-MM-DD HH:MM, but so far I am stumped.
Some gotchas (add to this list if you can come up with more difficulties that could crop up during the writing of such a function):
* leap years
A few examples of timecodes from the last few weeks:
1054746806
1054555725
1056715898
OK, that is my question. Have you done this before?
Have a nice day, folks.
Olle
Lund, Sweden
|
|
|
|
|
After doing a nice function to calculate how many seconds have elapsed since 1970-01-01 00:00:00 a workmate came by and whistled that I should do a DateDiff()
<br />
DateDiff("s", CDate("1970-01-01 00:00:00"), Now)<br />
Which was correct. Sigh. I'll try and make the other conversion, now. From seconds into days and years and months and...
See you.
Olle,
Shamed in a corner, Lund, Sweden
|
|
|
|
|
I believe this will work, but I didn't actually test it against any known Epoch date values.
Private Function GetEpochDate(ByVal seconds As Long) As DateTime<br />
Dim BeginningOfTime As New DateTime(1970, 1, 1)<br />
Return BeginningOfTime.AddSeconds(seconds)<br />
End Function
|
|
|
|
|
I regret that I am now working with VB6, and I'm also sorry I didn't include that into my first posting. I bow my head in shame. DateAdd() is my next stop, I guess.
Yep, it was!
<br />
Public Function GetEpochToDate(ByVal seconds As Long) As Date<br />
GetEpochDate = DateAdd("s", seconds, CDate("1970-01-01 00:00:00"))<br />
End Function<br />
Public Function GetDateToEpoch(ByVal theDate As Date) As Long<br />
GetDateToEpoch = DateDiff("s", CDate("1970-01-01 00:00:00"), theDate)<br />
End Function<br />
Thank you, Matt!
|
|
|
|
|
|
I want to access active web page objects like text boxes from VB application. I know it could be done using ActiveX. Can anyone help me How To Do It.
AJC
|
|
|
|
|
Hello,
I need some sound advice, here is the scenario: I have a mdiChild form that contains a button that launches a owned (owned by the mdiChild) form. My questions is: What is the most effective way to pass data from the owned form to the appropriate member variables declared on the mdiChild form (owner)?
Thanks in advance,
Andrew
|
|
|
|
|
It's alright I figured it out. I created a custom constructor for the owned form that accepts an instance of the mdiChild form.
Example:
(Owned Form Declaration)
Public Sub New(ByRef mdiChildInstance As frmMdiChild)
MyBase.New()
_mdiChildInstance = mdiChildInstance
End Sub
(OwnedForm Instantiation - code is located on the MdiChild Form)
Public OwnedForm As New frmOwnedForm(Me)
I also created public properties for all of the member variables on mdiChild.
Does anyone see any red flags with the code above?
Thanks,
Andrew
|
|
|
|
|
The memory footprint of this kind of coding is a serious problem.
|
|
|
|
|
So what is your suggestion?
|
|
|
|
|
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
|
|
|
|