Jump to content
Xtreme .Net Talk

donaldc104

Avatar/Signature
  • Posts

    33
  • Joined

  • Last visited

Everything posted by donaldc104

  1. You have to set up for column independence at item-add time. Example: itemNew.SubItems.Add("item1") itemNew.SubItems.Add("item2") itemNew.UseItemStyleForSubItems = False ' Cell independence... lvwTest.Items.AddRange(New ListViewItem() {itemNew}) Hey, I finally stumped the moderators on one! Do I get a badge or something? .
  2. SOLUTION: I change the color of individual cells in a List View control. I highlight cells in pink to show errors. lvwStats.Items(iIndex).SubItems(3).BackColor = Color.LightPink Normally my ListView is all white, with scattered cells highlighted in pink.
  3. This is easier to read. A lighter blue background.
  4. The dark blue background used by DotNetForums makes the black text hard to read. I suggest a lighter shade of blue.
  5. Problem fixed - the reference is named "Microsoft Scripting Runtime". It was buried in a very long list of items starting with Microsoft.
  6. I don't have "Microsoft Windows Scripting Runtime" in my list of components. Is it a special add-on?
  7. The HDD number should be good enough - thanks! But how do I reference Microsoft Windows Scripting Runtime ?
  8. Can the framework read the MAC address from Ethernet card? Or any other machine-specific data?
  9. This works great - thanks ! This works great ! Thank you very much, Divil ! Just one small typo: "Tab" not "Tag" NG: TabControl1.SelectedTag = TabPage1 OK: TabControl1.SelectedTab = TabPage1 I searched high and low and couldn't find this. But it's so obvious after you spell it out.
  10. Is there a way to "mouse-click a tab" on the top of a TabControl from code? I've tried several tactics but can't make it work yet.
  11. How can I read the machine-specific ID code (CPU serial number) ? Is there a disk-specific ID code on each hard disk? Are these functions supported by the framework or VB.NET? What are the common or technical names for these ID-codes?
  12. I'm having trouble catching a Timeout Exception. I can catch it generically with "Catch exc As Exception" and then identify it by its hash code, but this seems like a hack. I've searched the docs and tried many experiments but can't find the "right" way to catch it. This is a serial port read timeout. Can anyone help? Here's my code. Try ' Flush the COMM buffer: Read until no more chars: timeout. While (m_CommPort.Read(1) <> -1) ' LOOP: Poll & read. iChars += Chr(m_CommPort.InputStream(0)) ' Read any residue chars. iCharCount += 1 ' Count residue chars. lblEmStatus.Text = "Flushed " & iCharCount & ",=<" & iChars & ">" ' Display residue chars. End While ' A TimeOut exception here means "flush is completed, port is clear".-------------- 'Catch exc As System.IO.IOTimeoutException '---THIS WONT COMPILE: NOT DEFINED.-- 'Catch exc As System.Runtime.InteropServices.IOTimeoutException '---THIS WONT COMPILE: NOT DEFINED.-- 'Catch exc As System.IO.StringReader.IOTimeoutException '---THIS WONT COMPILE: NOT DEFINED.-- Catch exc As System.IO.IOException '---THIS COMPILES BUT NEVER CATCHES ANY EXCEPTIONS.-- MsgBox("System.IO.IOException") Catch exc As ServiceProcess.TimeoutException '---THIS COMPILES BUT NEVER CATCHES ANY EXCEPTIONS.-- MsgBox("ServiceProcess.TimeoutException") Catch exc As Exception ' THIS CATCHES ALL EXCEPTIONS OK. Dim ExceptionType As System.Type ExceptionType = exc.GetType() strErrMsg = exc.Message.ToString ' Text Error Message. iHashCode = exc.Message.GetHashCode MsgBox("Generic Exception " & iHashCode & "=<" & strErrMsg & ">") ' ' codes= -11889027343=NotOpen, +1218191172=Timeout End Try Where can I look up these mysterious codes ? They are not valid HRESULTS. I need to find out the Exception Types that correspond to these codes.
  13. I don't see any answer in using GetType. In both my test cases, exc.GetType() yielded NO distinguishing info. It says only "System.ApplicationException" I need to discriminate between TimeOuts and NON TimeOuts. The only way I see to do this is through exc.Message.GetHashCode. (or its even clumsier sibling exc.Message.ToString) Is there something here that I'm missing? :confused:
  14. Good suggestion (thanks!) but no luck. HashCode is still the only known method to make my program work. I tested two error cases: 1. Port Not Open and 2. Timeout. The only way to tell the difference between them is HashCode. Here's the code I used: Catch exc As Exception Dim ExceptionType As System.Type ExceptionType = exc.GetType() ' Error GetType strErrMsg = exc.Message.ToString ' Text Error Message. iHashCode = exc.Message.GetHashCode ' Error HashCode Console.WriteLine("TEST1 GT=" & exc.GetType().ToString() _ & ", H=" & iHashCode & ", M=" & strErrMsg) Here are the outputs from the two tests: TEST1 GT=System.ApplicationException, H=-108330557, M=Please initialize and open port before using this method TEST1 GT=System.ApplicationException, H=-1549478346, M=Read Error: Timeout error I tested on two different machines, both Win2000 but different configurations. Identical results. The HashCode numbers are constant, so this seems reliable. Maybe this will remain one of those unanswered questions.
  15. The GetType technique gets a LOT of data. But I don't see TimeOut anywhere. :cool: Here's what I tried. Catch exc As Exception Dim ExceptionType As System.Type ExceptionType = exc.GetType() I set a breakpoint and did QuickWatch on ExceptionType (results below). Lots of data but nothing seems useful. I dug down several layers into the sub-items, but found only mud. The Message.GetHashCode technique I'm using now seems to be reliable although clumsy. I would prefer to use the "right" method, if only I could find it. There has to be a TimeOut somewhere in this dark Microsoft cave. :cool: - ExceptionType {System.RuntimeType} System.Type + [system.RuntimeType] {System.RuntimeType} System.RuntimeType + System.Reflection.MemberInfo {System.RuntimeType} System.Reflection.MemberInfo DefaultLookup 28 System.Reflection.BindingFlags + FilterAttribute {System.Reflection.MemberFilter} System.Reflection.MemberFilter + FilterName {System.Reflection.MemberFilter} System.Reflection.MemberFilter + FilterNameIgnoreCase {System.Reflection.MemberFilter} System.Reflection.MemberFilter + Missing {System.Reflection.Missing} Object Delimiter "."c Char EmptyTypes {Length=0} System.Type() + defaultBinder {System.DefaultBinder} System.Reflection.Binder + valueType {System.RuntimeType} System.Type + enumType {System.RuntimeType} System.Type + objectType {System.RuntimeType} System.Type MemberType TypeInfo System.Reflection.MemberTypes DeclaringType Nothing System.Type ReflectedType Nothing System.Type + GUID {System.Guid} System.Guid + DefaultBinder {System.DefaultBinder} System.Reflection.Binder + Module {System.Reflection.Module} System.Reflection.Module + Assembly {System.Reflection.Assembly} System.Reflection.Assembly + TypeHandle {System.RuntimeTypeHandle} System.RuntimeTypeHandle FullName "System.ApplicationException" String Namespace "System" String AssemblyQualifiedName "System.ApplicationException, mscorlib, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" String + BaseType {System.RuntimeType} System.Type TypeInitializer Nothing System.Reflection.ConstructorInfo Attributes 1056769 System.Reflection.TypeAttributes IsNotPublic False Boolean IsPublic True Boolean IsNestedPublic False Boolean IsNestedPrivate False Boolean IsNestedFamily False Boolean IsNestedAssembly False Boolean IsNestedFamANDAssem False Boolean IsNestedFamORAssem False Boolean IsAutoLayout True Boolean IsLayoutSequential False Boolean IsExplicitLayout False Boolean IsClass True Boolean IsInterface False Boolean IsValueType False Boolean IsAbstract False Boolean IsSealed False Boolean IsEnum False Boolean IsSpecialName False Boolean IsImport False Boolean IsSerializable True Boolean IsAnsiClass True Boolean IsUnicodeClass False Boolean IsAutoClass False Boolean IsArray False Boolean IsByRef False Boolean IsPointer False Boolean IsPrimitive False Boolean IsCOMObject False Boolean IsGenericCOMObject False Boolean HasElementType False Boolean IsContextful False Boolean IsMarshalByRef False Boolean HasProxyAttribute False Boolean + UnderlyingSystemType {System.RuntimeType} System.Type
  16. Immediate problem fixed - thanks! But I'm still having a problem. No, I was not in run mode- something else was jammed up. So I quit and restarted VisualStudio, and then I was able to add the DLL reference OK. :) But the code does not seem to catch TimeOut exceptions. Here's what I have: Catch ex As System.ServiceProcess.TimeoutException strErrMsg = ex.Message.ToString ' Text Error Message. iHashCode = ex.Message.GetHashCode Catch exc As Exception strErrMsg = exc.Message.ToString ' Text Error Message. iHashCode = exc.Message.GetHashCode ' -108330557=Not open, -1549478346=Timeout All exceptions are caught under "Exception" only. The ServiceProcess.TimeoutException compiles OK but never executes. Code re-sequencing doesn't have any effect. Any ideas? :confused
  17. I'm blocked. I right click on References but the pop-up list has "Add Reference" greyed out. I dug through the framework docs but couldn't find any clues.
  18. How to reference ServiceProcess? Yes, this is what I want. Now, how do I add the reference to System.ServiceProcess.dll ? I've searched the docs and it is what I want. But there are no examples. Sorry to ask such basic questions.
  19. How to catch a Timeout Exception? "Catching a TimeoutException" is exactly what I want to do. How do I do it? I've searched the SDK docs. No luck (only obscure SQL timeouts). So far, my experiments have failed. Catch exc As System.IO.timeout Catch exc As System.timeout Catch exc As System.timeoutexception
  20. Thanks, I can see that this is the right way to approach it. But my application need is slightly different. Here's what I'm doing: I'm flushing all old residue out of a serial port. The process terminates when the READ times out. So I want to catch the timeout exceptions and handle them as normal. All other exceptions are true errors. Here's the code. Try ' Flush the COMM buffer: Read until no more chars. While (m_CommPort.Read(1) <> -1) ' LOOP: Poll & read. iChars += Chr(m_CommPort.InputStream(0)) ' iCharCount += 1 ' Count the number of Residue chars. lblEmStatus.Text = "Flushing..." & iCharCount & ", " & iChars End While ' TimeOut exception means "flush is completed". Catch exc As System.IO.IOException strErrMsg = exc.Message.ToString ' Text Error Message. iHashCode = exc.Message.GetHashCode MsgBox("System.IO.IOException" & iHashCode & strErrMsg) Catch exc As System.ApplicationException strErrMsg = exc.Message.ToString ' Text Error Message. iHashCode = exc.Message.GetHashCode ' -108330557=Not open, -1549478346=Timeout MsgBox("System.ApplicationException " & iHashCode & strErrMsg) Catch exc As Exception strErrMsg = exc.Message.ToString ' Text Error Message. iHashCode = exc.Message.GetHashCode ' -108330557=Not open, -1549478346=Timeout MsgBox("Exception " & iHashCode & strErrMsg) End Try If iHashCode = -1549478346 Then ' If TimeOut WriteStatus("Comm" & iPort & " flushed OK. " & vbCrLf & iCharCount & " Chars Residue=" & "(" & iChars & ")") Else WriteStatus("Comm Error #" & iHashCode & ", '" & strErrMsg & "'") End If Observations: 1. The System.Exception seems to be the superset of all the others more specific types. So I think it's what I want to use here. 2. The HashCode seems to be the way to discriminate TimeOuts exceptions. But the actual numeric codes don't seem to be documented? Is it safe to use the obscure value "-1549478346" as I've done?
  21. I'm successfully trapping I/O exceptions. I'm getting the exception text MESSAGE ok, this works great. But I need a type CODE (integer). Here's the program: Catch exc As Exception strErrMsg = exc.Message.ToString ' Text Error Message. Works great. iErrCode = exc.Message.GetTypeCode ' ??? Always=18 ?? How do I read the integer exception code?
  22. Problem Solved. Config Release vs Debug Problem Solved. Just confirming. Thanks for the fix, fellows ! I had left my CONFIGURATION MANAGER setting at RELEASE, and this apparently disables the debugger. I set it back to DEBUG, this fixed the problem. I wish the messages in VB.NET were more specific. Error numbers with a look-up reference would help.
  23. My Debugger stopped working abruptly. Error message = "? The breakpoint will not be hit. No symbols have been loaded for this document". How do I get it working again? I can't find this error message mentioned the on-line docs. Any clues would be appreciated.
  24. Protection for lvw.SelectedIndices You need to protect the index selection. Make sure that there is only one item selected before using SelectedIndices. Here's an example: If ListView1.SelectedItems.Count = 1 Then intIndex = Int(ListView1.SelectedIndices(0)) hope this helps. ;)
×
×
  • Create New...