|
64 bit,
i have looked at the support link with no resolution, any other idea.
|
|
|
|
|
I would like to know if I need to dispose of anything in this code
Dim frmToRnd As System.Windows.Forms.Form = Me
Dim regionRects(radius * 2 + 2) As System.Drawing.Rectangle
Dim circle As New Bitmap(radius * 2, radius * 2)
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(circle)
g.Clear(Color.White)
g.FillEllipse(Brushes.Black, 0, 0, circle.Width, circle.Height)
The rest of the code just uses what you see above. Do i use
Dispose.g
or do I need to dispose of regionRect and circle?
Thanks in advance for any help, time and patience.
rspercy60
rspercy
If "You wash your feet and find a pair of socks " Then
"You ARE a Redneck"
End If
|
|
|
|
|
You should dispose objects that are IDisposable[^] because those objects' classes do implement this interface to provide the method Dispose to release unmanaged resources.
In your code you should dispose the Bitmap and the Graphics objects.
You should also read about the Using statement[^].
Eslam Afifi
|
|
|
|
|
Thank you very much Eslam. I knew somethings have to be disposed of, but
I didnt know what. Once again, Thank You.
rspercy
If "You wash your feet and find a pair of socks " Then
"You ARE a Redneck"
End If
|
|
|
|
|
You're welcome.
Eslam Afifi
|
|
|
|
|
Hi Everybody!
I'm trying to capture all audio played through my computer's sound card to a WAV audio file. I've found a few examples like this one:
Sound Capture[^]
But they're all in VB6 and I'm struggling with the translation. Does anybody know of any examples in VB.NET that I could use to get an idea of how to accomplish this?
Thanks!
MrWolfy
|
|
|
|
|
Here is another one - I just used a search engine.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Hi!
Thanks for the link to the example, for it has answered some of my questions about working with WAV files in VB.NET. However, it does not seem to highlight how sound can be captured as it is played on a computer. Do you know of any examples that are capable of doing this?
MrWolfy
|
|
|
|
|
Can looping be used in the following manner?
for i=0 to 10
label i .visible =false
next
If not then kindly refer a solution to this querry.
|
|
|
|
|
No - in Vb.Net there is no concept of a "control array" and so you cannot.
An easy alternate is to create a set of labels and keep track of them via a collection like a List or an Arraylist .
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Abhinav S wrote: No - in Vb.Net there is no concept of a "control array"
That is nonsense.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Here[^] is Microsoft's response to "Control Arrays".
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Johan Hakkesteegt wrote: That is nonsense
Yes and no. There's no such thing as a control array, like we had in VB6 - and that's a good thing. The alternative is to keep your own list, or filter them out of an existing list.
The desired effect is similar, but it's not the conceptual equivalent of a control array.
I are Troll
|
|
|
|
|
He correct. In the old VB6, it was called a control array and it was a capability that came with nearly every control by way of it's Index property. Under VB.NET, that property doesn't exist so the VB6 concept doesn't apply.
The answer he gave was the correct one. Track the controls you want using some other container, either a collection, putting the controls in a Panel, Group, or some other container. The collection gives the illusion that VB6 gave you.
|
|
|
|
|
Johan Hakkesteegt wrote: Abhinav S wrote:
No - in Vb.Net there is no concept of a "control array"
That is nonsense.
Not nonsense. FACT !!! Although I know what you mean. Definately a step backwards from VB6. (Can't believe I just said that )
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
It can not be done as in your example, but it can easily be done looping through the controls within a container (your form, a groupbox or a panel, etc.).
For example:
Dim i As Integer = 1
'go through all the controls on the form'
For Each c As Control In Me.Controls
If c.Name = "Label" & i Then
c.Visible = False
i += 1
End If
Next
My advice is free, and you may get what you paid for.
|
|
|
|
|
This is what I would suggest
Private Sub HideLabels(ByRef Ctrl As Control)
Dim Lbl As Label = Nothing
For Each C As Control In Ctrl.Controls
If C.HasChildren Then
HideLabels(C)
End If
Lbl = TryCast(Ctrl, Label)
If Lbl IsNot Nothing Then Lbl.Visible= False
Next
End Sub
This tests to see if the control is a Label and, if so, set its Visible property. It also iterates through any child controls. Unlike CType , TryCast will attempt to convert the object and return Nothing if it cannot. Also, note the use if ByRef : you want to make sure you are changing the actual controls and not copies.
The advantage to this technique is that you don't have to worry about what you actually call the labels, so you can give them meaningful names. Just call this method with whatever container control you want, so
HideLabels(Me)
called in a Form would hide every Label on the form. Controls other than labels fail the TryCast and are not affected.
|
|
|
|
|
I am developing a MCQ based quiz and all is going well except that when i select the radio button of the second question the value of the variable of the first question (EL) changes to 2 instead it should be 1.?
And that I have declared two separate variables for the two questions.
Here is the code:
Public Class q1
Dim EL As Integer
Dim CS As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label5.Text = EL
End Sub
Private Sub RadioButton3_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
EL = EL + 1
Label5.Text = EL
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Visible = False
RadioButton1.Visible = False
RadioButton2.Visible = False
RadioButton3.Visible = False
Button1.Visible = False
Label2.Visible = True
RadioButton4.Visible = True
RadioButton5.Visible = True
RadioButton6.Visible = True
Button2.Visible = True
Label5.Text = EL
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Label2.Visible = False
RadioButton4.Visible = False
RadioButton5.Visible = False
RadioButton6.Visible = False
Button2.Visible = False
Label3.Text = EL
Label4.Text = CS
Label3.Visible = True
Label4.Visible = True
Label5.Text = EL
End Sub
Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
CS = CS + 1
Label5.Text = EL
End Sub
End Class
|
|
|
|
|
What do you mean mysteriously? The problem is that probably CheckChanged isn't doing what you think it should be. CheckChanged will increment when the control is first created and setup, will change again when the control is clicked and will probably change again when the other radio button is clicked, if it's in the same group.
|
|
|
|
|
Can you suggest any solution to it?
|
|
|
|
|
Well thanks a million Sir. I found a solution to the problem.
|
|
|
|
|
How can i make multiple forms in a project, having the same look (background color, font etc) in VB 2008?
|
|
|
|
|
If I understand your question correctly, then you first need to determine the lowest common denominator of the forms (font, color, default buttons that are on all forms, etc).
Create a regular windows form. Set the properties the way that you want them, save, then close the designer.
Add a new Windows Form to the project, but select the "Inherited Form" object instead of the "Windows Form" object. The wizard will ask you which form you want to base the new form on, so select the base that you previously created.
When the designed opens up, you will see all of the things that you had set it the original form (and you will not be able to change them), and your new form is ready for adding controls.
|
|
|
|
|
How can the objects such as texts of the labels can be made alterable in the inherited forms?
|
|
|
|
|
It should work the same way as custom controls. When your child form is initialized, it first calls the InitializeComponent method of the form from which it is derived, which calls its ancestor's InitializeComponent , and so on. Eventually it will hit your parent form, and all of the controls will be initialized. These cascade back up as ordinary properties.
|
|
|
|