|
AFAIK you can get and set RadioButton.Checked; setting it might fail if it is disabled.
And then there is RadioButton.PerformClick()
|
|
|
|
|
AFAIK?
Was able to get to the Checked property by converting the Control to a Radio Button using CType.
Private Sub ChecktheRadioButton(ByVal sName as String)
Dim ctr as Control
For Each ctr in GroupBox2.Controls
If ctr.Name = sName then
CType(ctr,RadioButton).Checked = True
Exit Sub
Next
End Sub
|
|
|
|
|
See, there is no problem whatsoever. Of course it has to be a Control that HAS a Checked property.
Now try this:
CType(GroupBox2.Controls(theNameOfMyTargetRadioButton),RadioButton).PerformClick()
|
|
|
|
|
Beautiful. That did the trick.
But still a bit confused - what is AFAIK
|
|
|
|
|
|
All of us must have come across the fact that some set of codes are specific to a particular OS only and incompatible with others. In some instances they may also lead to system crashes.
In such cases we need to track and identify the OS first and then proceed accordingly. So, here is how you can write a program in VB6.0 that can run in different Windows operating systems.
http://www.mindfiresolutions.com/Determining-host-operating-system-using-VB-6-189.php
Cheers,
Eliza
|
|
|
|
|
All very nice, but if you have to go back to the dark ages with VB6 then you should also handle windows millenium edition, windows 98, possibly windows 95 and variants of NT.
If this is to be of any use going forward you also need to support Windows 7.
Nowhere do you cover the server editions, which is an absolute must!
Plus of course you can get all this out of the box with .Net, and seeing as vb6 is definately a legacy language now, why bother.
|
|
|
|
|
NIce and all, but VB6 is a dead language and you're about 15 years too late to the party with this. The forums is also not the place to post such snippets. Post this in Tips/Tricks instead.
|
|
|
|
|
You can use "winmgmts" like this:
Private Sub Form_Load()<br />
strComputer = "."<br />
Set objWMIService = GetObject("winmgmts:" _<br />
& "{impersonationLevel=impersonate}!\\" _<br />
& strComputer & "\root\cimv2")<br />
Set colSettings = objWMIService.ExecQuery _<br />
("Select * from Win32_OperatingSystem")<br />
For Each objOperatingSystem In colSettings <br />
Label1.Caption = objOperatingSystem.Name<br />
Next<br />
End Sub
More properties in: http://msdn.microsoft.com/en-us/library/aa394239(VS.85).aspx
Hope be helpful
|
|
|
|
|
each time I run the follow code I get a runtime error.
Public Class menuitems
Public menuitem As String
Public itemcost As Double
End Class
'Dim totalorderquantity(12) as Integer
Public Class frmtodayscafe
Inherits System.Windows.Forms.Form
Public dr As DataRow
Public item() As menuitems
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim fileNamex As String = "menu1.txt"
Dim dirName As String = _
Path.GetDirectoryName(Application.ExecutablePath)
Dim dt As DataTable
Dim adapter1 As New OleDbDataAdapter
Using cn As New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;" & _
"Data Source=" & dirName & ";" & _
"Extended Properties=""Text;HDR=Yes;FMT=Delimited""")
' Open the connection
cn.Open()
' Set up the adapter
Using adapter As New OleDbDataAdapter( _
"SELECT * FROM " & fileNamex, cn)
dt = New DataTable("menuitems")
adapter.Fill(dt)
End Using
End Using
Redim item(dt.Rows.Count() - 1)
Dim drcounter As Integer = 0
For Each dr As datarow In dt.Rows
Debug.Print("{0} {1}", _
dr("Menu Items"), _
dr("Item Cost"))
item(drcounter).menuitem = dr("Menu Items").ToString
item(drcounter).itemcost = dr("Item Cost").ToString
drcounter += 1
Next
the run time error is Object reference not set to an instance of an object.
modified on Friday, March 19, 2010 6:50 PM
|
|
|
|
|
you never set the bounds on item() .
you need a
ReDim Preserve item(drcounter)
...or you could just do
Redim item(dt.Rows.Count() - 1)
|
|
|
|
|
Thanks, It worked. I used
Redim item(dt.Rows.Count() - 1)
to resolve issue after reading the data table.
|
|
|
|
|
glad it worked. Most of the time, we just need a separate set of eyes on our code. I can't tell you how many times I've gotten errors because I forgot a simple line of code.
|
|
|
|
|
compile-time errors and run-time exceptions tend to provide line numbers (assuming a debug build), so you should be able to easily find where the problem occurs, and then deduce where it originated.
|
|
|
|
|
resolved by William Winner
|
|
|
|
|
We have programs that require escalated privilege for certain small tasks as writing to HKEY/LOCAL_MACHINE for our own security keys.
Vista/Win 7 makes this very difficult. We do not want our apps to always to run as admin but only for the short time when we need to write out the HKEY/LM.
What is the way to do this programmatically? I do not mind if the user is asked to confirm or enter a password just need to be able to do it. I did see something about a ShellExecute "runas" but I rather not have another program. I would rather have it in 1 program.
Any ideas?
Thanks
|
|
|
|
|
QBTeKcom wrote: What is the way to do this programmatically?
You can't. I haven't seen anything that will allow you to do this. Either your app runs as an admin or it doesn't. Also, this only works if the user running it has an admin account available. An app cannot give itself more rights than the user that launched it already has.
|
|
|
|
|
QBTeKcom wrote: Any ideas?
have a post on vista/windows7 forum , might get some solution there. SOFTDEV
If you have knowledge, let others light their candles at it. [ Let's work to help developers, not make them feel stupid ]
|
|
|
|
|
Yeah I think you can only have an application run entirely as admin or not. You could probably do it by creating a separate project and spawning it from your current project - running it as admin. That might require creating a batch file that starts the new project with elevated privileges and running that batch file from your original project. Or there might be a way to do it when you spawn a new process - System.Diagnostics.Process.Start. There is an msdn article on it: http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/5a66c921-0d9c-483f-af3f-afa7f3e3b9c1[^]
|
|
|
|
|
Hello all,
I have been pulling my hair our trying to get this to work.
I created a DataSource programatically and applied it to a DataGridView.
Now, I want to add rows to that DataSource programatically and have it displayed in the DataGridView, but I can't for the life of me work out how to add to the DataSource....
I know there must be a relatively simple way to do this..
I can't add data to it in the usual way because the DataGridView is bound.
Any advice is much appreciated! =)
Here's the code for creating the DataSource and adding columns to it on form.load, and showing it in my DataGridView (named "dg"). This part of the code works fine:
Dim Table1 As DataTable
Table1 = New DataTable("Useful Links")
'------------------------------------------------------------
Dim adModel As DataColumn = New DataColumn("adModel")
adModel.DataType = System.Type.GetType("System.String")
Table1.Columns.Add(adModel)
Dim unId As DataColumn = New DataColumn("unId")
unId.DataType = System.Type.GetType("System.String")
Table1.Columns.Add(unId)
'------------------------------------------------------------
Dim ds As New DataSet()
ds.Tables.Add(Table1)
dg.DataSource = Table1
'------------------------------------------------------------
There will be a button (or something) to add rows to that DataSource.modified on Wednesday, March 17, 2010 9:14 PM
|
|
|
|
|
|
Thanks for the response but this doesn't appear to be what I'm after...
I am no expert (particularly with datatables) but the method you suggested appears to require a DataSet.
Like mentioned earlier, my data is created at runtime (called Table1) on form.load so I am unsure how to refer to it programmatically...
Forgive me if I am not making sense, or going the wrong way about all this, as previously mentioned I am not disciplined in datatables!
|
|
|
|
|
it is easy use like this
Dim dsObj As CRDataSet = New CRDataSet ' Your DataSource Here
dsObj.tablename.addmaintablerow(str1,str2,str3)If you can think then I Can.
|
|
|
|
|
If you're just binding the DGV to a single table, with no relations to other tables, you don't even need the DataSet. A DataSet is just a collection of DataTable object and DataRelations between them.
Since your DGV is bound to a DataTable, you just need to add a new row to the DataTable, not to the DGV. Look into the DataTable.NewRow method.
An alternative to doing it manually would be to create a BindingSource object, set it's DataSource to your DataTable, then set the DGV's DataSource to the BindingSource you created. All navigation and row handling is handled by the BindingSource object.
|
|
|
|
|
Thanks for the explanation Dave, that helped alot.
Gonna try a few of your suggestions now and see how I go
|
|
|
|