|
i get the answer.
Public Sub GetControls(ByVal owner As Form)
Dim fis As System.Reflection.FieldInfo()
fis = owner.GetType().GetFields(Reflection.BindingFlags.NonPublic Or _
Reflection.BindingFlags.Instance Or _
Reflection.BindingFlags.IgnoreCase)
For Each fi As Reflection.FieldInfo In fis
If TypeOf (fi.GetValue(owner)) Is Control Then
Try
boton = CType(Me.Controls(fi.Name.Substring(4, 6)), Button)
' MessageBox.Show(fi.Name.Substring(4, 6))
If boton.Name = "100" Then
boton.BackColor = Color.Gray
End If
Catch ex As Exception
End Try
End If
Next
End Sub
i create a var called "boton as Button" then use Ctype to get the number and then make the comparation, if is true change the color of the button.
i make a substring because the name of the buttons start in "_p1" and a number like 100,101.
that is all.
Thanks
|
|
|
|
|
Why use reflection for this?
If you know the name of the button, use this:
Button myButton = this.Controls["buttonName"] as Button;
myButton.BackColor = Color.Red;
This is a C# code and I assume you can write the equivalent in VB. Here "this" refers to the form in which the button is placed. In case the button is placed in some other container, use the control collection of that container.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Hi All,
I have a question about “Redim”. Consider a Class containing some Share public variant, for example double. The class is created in the main class as array with length ‘2’. If procedure repeats, it is needed that share public variant to be nothing or zero. For this, I Redim the array object created from class containing share public variant. The problem would be accrued when the object new again. In this condition the share parameter which had been deleted is valued again.
Public Class clsTest
Public Shared MyParametr As Double
Public Sub DoDesign()
MyParametr+=3
End Sub
End Class
Public Class MainForm
Public MyObject(1) As clsTest
Private Sub frmMain_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
MyObject(1) = New clsTest
MyObject(1).DoDesign()
Text1.Text= MyObject(1). MyParametr.Tostring()
End Sub
Public Sub DeletingDesignResult()
Ridim MyObject(0)’object=Nothing
Ridim MyObject(1)
End Sub
End Class
When MainForm Shows again and object is newed again, the value of MyParametr is ‘3’ and notzero.
|
|
|
|
|
I can't really understand what you are trying to achieve which makes your question difficult to understand.
Looks like you just need to rethink how your objects are instanced and relate to each other and redesign the code.
You maybe also need to do some testing of the shared object before setting a value to make sure it really needs to be set.
|
|
|
|
|
Experts,
I am using a vb6 application with ADO data controls, i am using a search option where i can find a particular record.
Current code: for search button
Adodc1.Recordset.Find "First_Name = '" & txtFirstName.Text & "'", , adSearchForward
this works fine, what i would like to be able to do is add the text "yes" to record Returned on a particular record by pressing a button Returned. (hope that makes sence!)
Intially the user will search for a record by typing a name in e.g bob
the curser thing of the database will then find record contiang bob and select that record
i then want a button to appear (btnRecord.show ) which will then allow that particular record selected in one of the fields to then have a "yes" on it.
If anybody can help that would be great.
Cheers
Dan
|
|
|
|
|
Hi All,
I have created an application in Visual Studio 2005 .NET, which I installed on my client's machine. This application/project has one file, 'Form2.vb', which needs some updation.
Now I want to update the installed application with this new/updated file without uninstalling the current version installed on my client's machine.
Can someone Please let me know how to do this. I dont want web updation, I can go to my client's machine and update the installed application.
Hope I am clear.
Regards,
R.S.
|
|
|
|
|
You just copy the resulting file of your project.
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
I have created a setup & deployment project and installed the exe on my client's machine. So there is no way to update that file on my client's machine.
One way is to recreate the whole SEtup & deployement project with the updated file and re-install on my client's PC, but I dont want to un-install the current version; I just want by anyhow if I can update the application.
|
|
|
|
|
Ok i am doing a login and creating account form i need help with the coding
I will show you guys what i have hopefully could get some guide on modifying the code
This is The Create Button...
If TextBox1.Text = "" Then
MsgBox("ERROR,Your Account/Username must have one letter in it!", MsgBoxStyle.Critical)
Else
If TextBox2.Text = "" Then
MsgBox("ERROR,Your Account/Password must have one letter in it!", MsgBoxStyle.Critical)
Else
Try
MkDir("C:\ACCOUNTS" + TextBox1.Text)
Dim username As New System.IO.StreamWriter("C:\ACCOUNTS" + TextBox1.Text + "\" + "username.txt")
username.Write(TextBox1.Text)
username.Close()
Dim password As New System.IO.StreamWriter("C:\ACCOUNTS" + TextBox1.Text + "\" + "password.txt")
password.Write(TextBox2.Text)
password.Close()
Catch ex As Exception
MsgBox("ACCOUNT CREATED", MsgBoxStyle.Information, "ACCOUNT CREATED")
End Try
End If
End If
This is the login button
If My.Computer.FileSystem.DirectoryExists(" C:\ACCOUNTS" + TextBox1.Text + "\") Then
Dim USERREAD As System.IO.StreamReader = New System.IO.StreamReader("C:\ACCOUNTS" + TextBox1.Text + "\" + "USERNAME.TXT")
Dim userline As String
Dim PASSREAD As System.IO.StreamReader = New System.IO.StreamReader("C:\ACCOUNTS" + TextBox1.Text + "\" + "PASSWORD.TXT")
Dim PASSLINE As String
Do
PASSLINE = TextBox2.Text
userline = USERREAD.ReadLine
Console.WriteLine(PASSLINE)
Console.WriteLine(userline)
Loop Until userline Is Nothing
MainScreen.Show()
Me.Hide()
If TextBox2.Text = "" Then
MsgBox("error, PLEASE INPUT A PASSWORD", MsgBoxStyle.Critical)
Else
If PASSLINE = PASSREAD.ReadLine() = True Then
End If
End If
Else
MsgBox("THE USERNAME DONT EXIT", MsgBoxStyle.Critical)
End If
I don need the database the information can be save in the mobile itself thanks
There is 1 using C# to make the login form but unfortunately my range is only on VB.net itself and i can't touch C# with this project
Will Be Grateful for all the peeps here that could guide me on it
Thanks
modified on Tuesday, January 19, 2010 3:36 AM
|
|
|
|
|
Why don't you try telling us what you want it to do?
|
|
|
|
|
Ok i just want a login system or let's say an login application for smart devices
it like when the application is activate it will prompt you to sign in to ur account and at the same time a form to create account for the login system . . .
but i don wan the normal source i want some source code for vb.net smart devices that's something that makes me very headache about
Sorry About That,
Thanks For Helping Out,
|
|
|
|
|
I'm not sure about the rest of the code, but this block concerns me:
Catch ex As Exception
MsgBox("ACCOUNT CREATED", MsgBoxStyle.Information, "ACCOUNT CREATED")
End Try
If an exception is caugth, that most likely means an error was encountered, which may mean that the account was not created. Catching all exceptions is probably not a great idea either, but that is beyond the scope of this question. I would suggest moving the "Account Created" message to immediately before the catch block and using the cath block to report any errors.
|
|
|
|
|
Thanks For The Advice,
My Main problem is i wanna create a login application that is for vb.net smart devices,cus i am totally new to vb.net smart device.
that code that i provide is the normal application i wan it to be the vb.net smart devices version. . .
maybe you can give some guide or like provide some source code for me for making the login system on vb.net smart devices.
Thanks
|
|
|
|
|
In the application I'm developing, I'd like to give the user the option to automatically start the application when windows starts. From my searches it looks like setting a registry key is one of the best ways to do it.
I haven't ever played with the Registry in my programs before (I've only ever manually edited the registry), so I want to make sure I get it right.
I came across MatrixCoder's article "Autorun Applications" which is quite clear and straight forward.
He uses the following sub and passes it System.Reflection.Assembly.GetEntryAssembly.Location for path in order to set the registry key.
Private Sub AddCurrentKey(ByVal name As String, ByVal path As String)
Dim key As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
key.SetValue(name, path)
End Sub
If the key already exists, will this just overwrite it, or will it add another key each time AddCurrentKey() is called?
If it would keep on adding further keys, how would the code best be modified to check if the key already exists?
Regards
Paul Hasler
modified on Tuesday, January 19, 2010 5:03 AM
|
|
|
|
|
Adding that key will not make your program automatically start when Windows starts. It will make your application start when a user logs on to Windows. When the user logs off the system, the program will be terminated if it is still running.
To make your application start when Windows starts, you need to make your application a "Windows Service". If you search for "Windows Service" you will get plenty of information on how to make it.
Good luck and happy programming!
|
|
|
|
|
This doesn't make the application start when Windows starts. This makes it start whenever the user logs in on the machine.
If the name is the same as an existing value, then that value will get overwritten. it will NOT create another copy of the same name/value pair.
|
|
|
|
|
Thank you once again Dave.
I used the wrong terminology. I do actually want the application to start when the user logs on.
You see so many programs today with preference options such as for example "Start Skype when windows starts", that I fell into the trap of using the same sloppy terminology.
With your explanation of how this will behave, I can finish off my app.
Cheers again
Paul
|
|
|
|
|
hi all
am using vb.net 2.0 and crystalreports XIR2 am getttingthis error
can u advice why this type of error is comming
Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
Regards
Vidhish
|
|
|
|
|
|
hi Thomas.
filedname type is FCCurrency Char(3)
Regards
Vidhish
|
|
|
|
|
Can you show us in code where you are getting this error?
I've had this error show up when I use parameters in reports...
|
|
|
|
|
I was asking for the NAME of the field in the report (you know, this things with @....).
|
|
|
|
|
Hi Thomas ,
parameters are
@BranchCode
@CostCode
@AcountCode
@FromDate
@ToDate
Regards
Vidhish
|
|
|
|
|
I'm trying to access a USB port from visual studios 2008 and I want to communicate with a micro controller. We are trying to send three commands to the micro controller, they are Start, Stop and Reset. We have developed the code for the GUI but have no idea how to send this information to the USB port. Also we are trying to determine how to get feed back from the micro controller so we can plot a graph in visual studios 2008. Can anyone help me please?
Thanks,
Josh McGill
|
|
|
|
|
If the microcontroller treats the USB port just like a serial port then all you would do is open the ports and read and write the data in the normal way. Look at My.Computer.Ports
You would need to program the microcontroller to spit out the data to the serial port in a known format, so you could listen for and handle those messages.
What type of microcontroller are you using?
Search google.....there is a shedload of info relating to the net on this subject.
|
|
|
|