|
Hmmm... I never knew about that one.
|
|
|
|
|
Oh .. Never mind
|
|
|
|
|
Hi:
I have a problem, i'm programming under vb.net 2005 express edition, i have a main window with some panels with controls over they, well, i have a track control who is scroll to change the window opacity, i was this method in another programs and the window change the opacity without problems, but in this program my windows is darkness when i change the opacity value, only first time, why?.
The track control is over slipt panel but i need this panel to what the user change the meters of panel, could be the problem reason?, if yes what could im made?, thanks very much for your help
|
|
|
|
|
Hi haggenx,
I also have the same problem . Sometimes it runs ok & sometimes it shows the Darkness. I think it may be because of Graphic card or.. ??
Thanks,
Dan
|
|
|
|
|
oops, and not exist a method to cancel this problem? , well, thanks very much for your help.
|
|
|
|
|
Hi,
Yes I'm still looking for the answer and whenever I will get it I will post it here
Dan
|
|
|
|
|
well, thanks for your help
|
|
|
|
|
I have an XmlDocument (System.Xml) that i want to add to and do various other stuff but i want to split the routines down. I've read that ByVal is 'safer' to use and possibly quicker than byref so i am proposing to layout my functions as below...
Imports System.Xml
'Declaration
Dim XmlDocObject as New XmlDocument
XmnlDocObject = InitialiseXml(XmlDocObject)
Private Function InitialiseXml(ByVal v_XmlDocObject as XmlDocument) as XmlDocument
'Temp object
Dim TempXmlObject = v_xmlDocObject
'Do something with temp object......
'Return object now processing is finished
Return TempXmlObject
'Destroy temp object
TempXmlObject = Nothing
End Function
What i would like to know is if the above is good / bad practice?
Anything thing wrong with this way?
Is this the preferred way as opposed to using Byref or am i creating extra objects which will
lie around in memory (until GC see fit to get rid)?
Regards
|
|
|
|
|
Your code is incorrectly written so it really doesn't matter which one you use. What you've done is definitely bad practice. No, ByVal is not "safer", nor is it "quicker". The two are used for different reasons.
The way you're writing your code, you're writing a function that returns an XmlDocument, the one that's passed in, and you don't have to.
Since you're passing in a Reference type (any class instance), ByVal passes the reference to the object, not the object itself. Passing in an object ByRef passes in a reference to the reference of the object, which doesn't really give you anything. So, since your function is getting a reference to the object on the heap, it can modify that object and not return anything.
Dim XmlDocObject As New XmlDocument
InitializeXml(XmlDocObject)
Private Sub InitializeXml(ByVal xmlDocument As XmlDocument)
' Do whatever you need to do to "xmlDocument"
' Do not "return" anything since you're modifying
' the original object.
End Sub
|
|
|
|
|
Thanks, i'm currently upgrading from VB6 to .net and want to start off on a firm footing employing some good practices.
I agree with Dave's response, anybody else with an opinion more than welcome though.
Many Thanks
|
|
|
|
|
Hi,
Does anyone have any examples in VB/VB.NET on how to either merge 2 wav files togetger or to play them consec utively in code ?
Thanks
|
|
|
|
|
If the files have the same sample rate, sample size (bits, sign) and mono/stereo setting, you can just extract the data from the files, merge and save with a new header.
---
single minded; short sighted; long gone;
|
|
|
|
|
"just" might be pushing it a bit as there are a number of possible encodings, some of which requires knowledge of the encoding to combine.
|
|
|
|
|
Open that files in binary mode and just add the beginning of the second to the end of the first.
But also you will have to change the header info. Just the file Size part.
|
|
|
|
|
I need to copy all files from one file to another..Could someon help
|
|
|
|
|
check
System.IO.Directory.GetFiles()
System.IO.File.Copy()
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
If you're using VB.NET 2005, you can use that handly little "My":
<br />
For Each sfile As String In My.Computer.FileSystem.GetFiles( My.Computer.FileSystem.SpecialDirectories.MyDocuments,FileIO.SearchOption.SearchAllSubDirectories,"*.*")<br />
<br />
My.Computer.FileSystem.CopyFile(sFile, "C:\Lalala")<br />
Next<br />
|
|
|
|
|
Could you please explain wat is going on
|
|
|
|
|
sure
to find all the files in a folder, and do something with each file (like copy them) i used the "For Each" statement.
For Each sfile As String In My.Computer.FileSystem.GetFiles( ..
so sfile is a string with all the filenames located in the specified folder (in my case, My Documents)
<br />
My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, FileIO.SearchOption.SearchAllSubDirectories, "*.*")
or could be anything, like
My.Computer.FileSystem.GetFiles("C:\Tatata")
then each file was given the command to be copied to "C:\Lalala"
My.Computer.FileSystem.CopyFile(sFile, "C:\Lalala")
and then ends the loop:
Next
i hope that helps.
|
|
|
|
|
Thanks a lot....That was my requirement i will try it outt
|
|
|
|
|
This Function can do for u !!!!
Imports System.IO
Public Sub CopyDir(ByVal strSrc As String, ByVal strDest As String)
Dim dirInfo As New DirectoryInfo(strSrc)
Dim fsInfo As FileSystemInfo
If Not Directory.Exists(strDest) Then
Directory.CreateDirectory(strDest)
End If
For Each fsInfo In dirInfo.GetFileSystemInfos
Dim strDestFileName As String = Path.Combine(strDest, fsInfo.Name)
If TypeOf fsInfo Is FileInfo Then
File.Copy(fsInfo.FullName, strDestFileName, True)
'This will overwrite files that already exist
Else
CopyDir(fsInfo.FullName, strDestFileName)
End If
Next
End Sub
While Copying , if the source dir content large file your GUI will be hanged,,,, so u can use Background worker along with that methods
Happy Programming
-----
Abhijit
|
|
|
|
|
This works perfectly fine...Thanks a lot
|
|
|
|
|
i need to download Attachment from Email in Outlook using VB,NET. Could someone help
-- modified at 9:14 Monday 15th October, 2007
|
|
|
|
|
|
Hi all,
I have 2 forms (Form1 and Form2) in my app. Form1 has 2 buttons (Button1 and Button2). The Load event of Form2 has this code:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
Dim obj(,,) As Object<br />
ReDim obj(50, 24000, 100)<br />
End Sub<br />
When you click Button1 on Form1 this code is executed:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Dim obj(,,) As Object<br />
ReDim obj(50, 25000, 100)<br />
End Sub<br />
The ReDim statement gives an OutOfMemoryException. When I change the statement to
ReDim obj(50, 24000, 100)
the exception isn't thrown anymore.
When Button2 is clicked, this code is executed:
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click<br />
For tel As Integer = 1 To 10<br />
Dim f As New Form2<br />
f.Show()<br />
Next<br />
End Sub<br />
This works just fine.
After searching the web for answers, I think it may have to do with the heap size, but I'm not sure at all.
My questions:
Why is the Button1 code giving an exception and why is this not happening when clicking Button2?
What should I do to make the Button1 code work without throwing an exception?
Skippy II
|
|
|
|
|