|
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.
|
|
|
|
|
There is a gotcha that you should be aware of...
If you do much of anything in your load routine. In the base for you will want to put all of that stuff into an if statement that only executes when not in the designer.
I am not sure why this is but fought this for about a week.
So you would put code in the load routine in an if like this
If Not DesignMode Then
'DoStuff
End If
Also be aware that usually you will want to design the base form then BUILD the project before adding the inherited form.
Humble Programmer
|
|
|
|
|
Visual Designer executes parts of your code, that is how it renders the Forms and User Controls you create. Unfortunately I don't have any details around.
|
|
|
|
|
|
well you have two ways:
1- you can create it by coding:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SecondForm As New Form1
SecondForm.Show()
End Sub
in this way the button that i included has the same execution that is in the first form (it includes the same codes to execute)
2- Add new form, go to the first form and select all controls then copy and past to the new form!
|
|
|
|
|
I am not sure if this is possiable but I am looking to build an application that will login to a web site, navigate the site and download files. I would like to do this all in code and able to run multiple instances of the program to get information from many different web sites. Is something like this possiable in VB.net? Any help or direction on this subject would be helpful. Thanks.
|
|
|
|
|
I believe the technology you are looking for is called a "web crawler". Search around and you might find something that has already been built that you can use for your purpose.
The quick answer to your original post is, Yes, you can programatically navigate a website and download data. Another search term might be "screen scraping".
Best of luck.
|
|
|
|
|
Hi Experts,
I have developed a database driven software which requires few dll's that I have used in my project. When I created the Deployment project and deployed to my client with that. There was a problem with dll path.
However I have fixed the same by creating a directory structure and placing dlls into that. Some dlls required to be placed in my application folder. However I had done and changed the same in my deployment project.
But what if I don't want to place that dlls in my application directory and like to keep in windows\system and how would my exe be reference to a new path. That is my question.
I hope you understood my problem.
I am using VS 2005 IDE with vb.net Lang and MS-Access as DB.
Thanks in advance.
Jay Khatri
|
|
|
|
|
If your .DLL's are COM-based, you added a Reference to them, you can put them anywhere. You just have to remember to register them with REGSVR32 when they are in their permanent location.
If the .DLL's are library .DLL's, you get at the functions they expose with P/Invoke, the .DLL's have to either be in the directory that the .EXE is in or in a folder in the system's PATH environment variable.
|
|
|
|
|
I have the following subroutine to list the tables from a selected SQL Server database. In this case AdventureWorks.
Private Sub DisplayDatabaseTbls(ByVal tblTables As DataTable)
lstTbls.DataSource = Nothing
lstTbls.Items.Clear()
For Each row As DataRow In tblTables.Rows
lstTbls.Sorted = True
lstTbls.DataSource = tblTables
lstTbls.ValueMember = "Table_Name"
lstTbls.DisplayMember = "Table_Name"
Next
End Sub
It retrieves the database tables just fine, but when I open up the same database in Microsoft SQL Server Management Studio Express I noticed that the tables where listed differently.
Example:
My Subroutine list the tables like this:
AWBuildVersion
Department
Employee
While SQl Server Management Studio list them like this:
dbo.AWBuildVersion
HumanResources.Department
HumanResources.Employee
Can someone tell me how I can make my subroutine match the SQL Server Management Studio?
Thanks in advance,
Quecumber256
|
|
|
|
|
Does VB.NET have any hidden understanding of units of measure? Meaning, if I had a value 12 oz and wanted to quickly decide if it is greater than or less than 500 mL, is there something out there that already can do that in VB?
I know that I can give a weight to each UOM and do the comparisons but am hoping there might already be something in the vast framework of code. I couldnt find anything by searching the net for VB but did find stuff for F#. I dont believe I can program with F# though, or at least it isnt available as a project template.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Nothing inherant, but it is easy write conversion programs.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
I have conversion code already, I was just hoping to find a more complete codebase to use rather than re-inventing the wheel.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
|
Do not crosspost.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|