|
It's not possible to do the way you're thinking. But, you can wrap the suspected variable in a Property, then the rest of your code can change that value through the property's Set code. Your can set you're breakpoint on that set code to get the result you want.
|
|
|
|
|
Dave Kreskowiak wrote: It's not possible to do the way you're thinking.
Grumble, grumble. Another thing I hate about .Net then! I also hate the fact that if you copy and paste code into the immediate window (todo a debug print) that is either split on multiple lines or within a "With" statement, that you must retype the full name and remove the carriage returns. VB6 just prints out the values.
Dave Kreskowiak wrote: But, you can wrap the suspected variable in a Property, then the rest of your code can change that value through the property's Set code. Your can set you're breakpoint on that set code to get the result you want.
Great idea Dave.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Normally, the only thing in a class that should be modifying the private backing variables for a property IS the property code. Yes, you can, and really should, have private properties inside classes. You can then use Trace Breakpoints on those properties. A Trace Breakpoint gives you the option of logging a message, variable values, call stack, whatever..., and then continuing execution of the code, without stopping. It's excellent for logging all changes to a variable from everywhere.
|
|
|
|
|
I previously haven't used a private property for class level variables, but I can see the proper use and benefit now with your explanation. Thanks for the pointers with private properties and tracing.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
No problem!
|
|
|
|
|
How to check System DSN name is already configured or not before creating a new DSN using VB.net2005
Saseendran Kombath
|
|
|
|
|
System DSN's (why would even need one in this day and age?) are stored in the Registry under
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ . All you have to do is check there. I suggest opening up Regedit and looking around before you start writing code.
|
|
|
|
|
Check name(as String value) is present under following registry key or not?
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC DATA Sources.
For Example:
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC DATA Sources(Key) "OrcInfoCtr"(String value) "Oracle in OraClient11g_home1"(Data Value)
ashish
|
|
|
|
|
You obviously found the registry key in regedit. Isn't what you see there pretty obivous??
The DSN name would be a value under "ODBC Data Sources", then it's settings are in a folder of that name under ODBC.INI.
Honestly, how hard is it to see what's going on in there? And why are you replying to a message that's two and half years old??
|
|
|
|
|
I'm using this class Rs232 to call phone number as it happen in the commnication >> hyper terminal .. in XP-PC
I'm using the name of Modem instead of the number of port,the same way in the hyper terminal.. so is this possible and will it succees with?
Dim rs As New RS232.Rs232<br />
rs.Port.ToString("Softv92faxmodem")<br />
rs.Open()
|
|
|
|
|
I would have thought it would have been quicker to try it than post the question.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
The ony;l way to tell is to try it. Though, I seriously doubt it'll work this way.
You're best source of information and support is the people who wrote the library you're using.
|
|
|
|
|
i treid this but it didn't usccees, it didn't opem the connect.
Imports RS232.Rs232
Dim rs As New RS232.Rs232
With rs
.Port.ToString("SoftV92FaxModem")
.BaudRate = 2400
.DataBit = 8
.StopBit = RS232.Rs232.DataStopBit.StopBit_1
.Parity = RS232.Rs232.DataParity.Parity_None
.Timeout = 500
End With
rs.Open()
rs.Write(Me.TextBox1.Text)
|
|
|
|
|
I really hate repeating myself. First, the best source of support for any library you use is the people who wrote that library. Second, Port is usually going to be "COM1", "COM2", "COM3", ... or whatever the library supports. It LOOKS like this one only understands the COM designations, so:
Dim rs as New RS232.Rs232
With rs
.Port = "COM3"
.BaudRate = 2400
.DataBit = 8
.StopBit = RS232.Rs232.DataStopBit.StopBit_1
.Parity = RS232.Rs232.DataParity.Parity_None
.Timeout = 500
End With
rs.Open()
rs.Write(Me.TextBox1.Text)
Also, the communication parameters MUST be correct, otherwise, you'll either get nothing on the receiving device or you'll get garbage. Double-check with the device to verify what parameters you are supposed to use.
|
|
|
|
|
Hi,
I am trying to change the status of checkbox using SendMessage. For some reasons it's not working. Can anyone fix this for me? below is my code:
Imports System.Runtime.InteropServices
Public Class Form1
Private Const BM_GETCHECK As Long = &HF0
Private Const BM_SETCHECK As Long = &HF1
Private Const BS_AUTOCHECKBOX As Long = &H3
Private Const BST_CHECKED As Long = 1
Private Const BST_UNCHECKED As Long = 0
<DllImport("user32.dll")> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CheckBox As Control
CheckBox = CheckBox1
Dim value As IntPtr
value = CheckBox.Handle
SendMessage(value, BM_SETCHECK, BST_CHECKED, 0)
End Sub
End Class
Thanks in advance,
Scot
|
|
|
|
|
Isnt' that a bit extravegant when you could do the exact same thing with:
CheckBox1.Checked = True
Perhaps you've left out some details of what you intend to do with this?
|
|
|
|
|
Yes. Sorry, I didn't explain the purpose. This is just a sample spike application that i am trying to get working. The actual implementation is quite different where using API calls I am trying to check another compiled .NET application's checkbox.
-Thanks
modified on Thursday, December 18, 2008 11:42 PM
|
|
|
|
|
With inspiration from the following web site https://bytes.com/topic/net/answers/637107-how-find-out-if-check-box-checked I solved it like this in C# (it shouldn't be too hard to convert to Visual Basic):
using Accessibility;
[DllImport("oleacc.dll", PreserveSig = false)]
[return: MarshalAs(UnmanagedType.Interface)]
public static extern object AccessibleObjectFromWindow(IntPtr hwnd, uint dwId, ref Guid riid);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, StringBuilder lParam);
public static Nullable<bool> isCheckBoxChecked(IntPtr checkBoxHandle)
{
const UInt32 OBJID_CLIENT = 0xFFFFFFFC;
const int UNCHECKED = 1048576;
const int CHECKED = 1048592;
Guid uid = new Guid("618736e0-3c3d-11cf-810c-00aa00389b71");
IAccessible accObj = (IAccessible)AccessibleObjectFromWindow(checkBoxHandle, OBJID_CLIENT, ref uid);
object o2 = accObj.get_accState(0);
if ((int)o2 == UNCHECKED)
{
return false;
}
else if ((int)o2 == CHECKED)
{
return true;
}
else
{
return null;
}
}
public static void setCheckBoxChecked(IntPtr checkBoxHandle, bool shouldBeChecked)
{
bool isChecked = (bool)isCheckBoxChecked(checkBoxHandle);
if ((!isChecked) && (shouldBeChecked))
{
SendMessage(checkBoxHandle, BM_CLICK, 0, null);
}
else if ((isChecked) && (!shouldBeChecked))
{
const UInt32 OBJID_CLIENT = 0xFFFFFFFC;
Guid uid = new Guid("618736e0-3c3d-11cf-810c-00aa00389b71");
IAccessible accObj = (IAccessible)AccessibleObjectFromWindow(checkBoxHandle, OBJID_CLIENT, ref uid);
accObj.accDoDefaultAction(0);
}
}
|
|
|
|
|
The project I am currently working on involves communication with multiple embedded devices over a network.
I have managed to get to the point where I am getting all of the required information back from the devices, however, until runtime I do not know how many devices there will be.
I have defined a class for the devices which i have called 'unitclass', which has variables for all of the necessary data such as MAC address etc.
What I am wondering, is how can I create new instances of this class at runtime via iteration, ie
for n = 1 to (number of devices)<br />
dim n as new unitclass<br />
next n
Thanks, Chris
|
|
|
|
|
If I am understanding your question correctly, what I would do is add each UnitClass object which is created during your loop to a collection along with a key so that you can access each object when needed.
Please let me know if I have got the wrong end of the stick!
|
|
|
|
|
The problem i have got is that the little code snippet i wrote will not work.
I do not seem able to create an object at run time using the contents of a variable as the object name.
|
|
|
|
|
It won't work for a couple of reasons. First, you reusing your loop variable as an instance of an object. What is n supposed to be?? Is it the loop variable or is it an object? It can't be both.
Second, your creating an instance of a class and then, on the next iteration of the loop, your replacing that instance with a new one. On top of that, since you're not adding these instances to a collection anywhere, the only remaining instance, when the loop terminates, goes out of scope and is destroyed. You have to add these to a collection somewhere to hang onto them.
|
|
|
|
|
The purpose of the for loop was more to help explain what I want to do than anything else.
How would i create n instances of an object, named object 1, 2, 3, ... n. where n is unknown until the app receives n UDP Datagrams at runtime?
I do intend to add them to an arraylist and sort by a particular variable using icomparable.
Regards, Chris
|
|
|
|
|
Why would you want to create named objects anyway?? It's easily done with an array or HashTable. A hashtable example:
Dim myCollection As New Hashtable
For n As Integer = 1 to m
Dim newObject As New SomeClass
myCollection.Add(n, newObject)
Next
|
|
|
|
|
So,ething like this should work:
Dim colObjects as new collection
For n as Integer = 0 to (number of devices)
colObjects.Add(new UnitClass(), n.toString)
Next
You can then access each object of the collection like this (replacing 1 with the number of the object:
Ctype(colObjects.Item("1"), UnitClass).<<property name>> = <<property value>>
Hope this helps
|
|
|
|