Jump to content
Xtreme .Net Talk

kejpa

Avatar/Signature
  • Posts

    321
  • Joined

  • Last visited

Everything posted by kejpa

  1. No, it's not putting the items into the combobox that's the problem. It's not getting the currently selected either. It's selecting the item based on a value, which is not the text of the items. When initializing the Combo I do... Dim oType As New ArrayList() ' ccboItem contains members Item, Value oType.Add(New ccboItem(30, "0..20mA")) oType.Add(New ccboItem(31, "4..20mA")) cboType.DataSource = oADDAType cboType.DisplayMember = "Value" cboType.ValueMember = "Item" cboType.SelectedIndex = -1 Reading my database gives me the value of 31 for type cboType.SelectedValue = oItm.Type ' oItm.Type=31 And I want to see "4..20mA" in the combobox OOOOM?!?! Typo? OOP.... OOP.... OOP... Still pissed. :mad: /Kejpa
  2. Hi, I'm furious! :mad: After finding out that you don't have the ItemValue property any more which disables you from hardcoding the Item/Itemvalue to a combobox I decided to go with the samples in the help and assign a arraylist to the datasource. When I read my database I get the ItemValue for the combobox. How the f**ing h*ll am I to set the item shown in the combobox? cboType.SelectedValue = oItm.Type will not work, SelectedValue is nothing! Plz help and exsqueeze my dirty language in this post. /Kejpa
  3. Hi, I'm having a object hierarchy where I want to raise events in the derived classes but it's not working the way I want it to. Public Interface iSensor Event NewData(ByVal SensorValues() As Integer, ByVal TimeStamp As Single, ByVal Sensor As iSensor) . Sub ReadSensor() . End Interface Public MustInherit Class c485Sensor Implements iSensor Public Event NewData(ByVal SensorValues() As Integer, ByVal TimeStamp As Single, ByVal Sensor As iSensor) Implements iSensor.NewData Public MustOverride Sub ReadSensor() Implements iSensor.ReadSensor . End Class Public Class c485Specialized Inherits c485Sensor Public Shadows Event NewData(ByVal SensorValues() As Integer, ByVal TimeStamp As Single, ByVal Sensor As iSensor) . Public Overrides Sub ReadSensor() RaiseEvent(imodValues, DateAndTime.Timer,Me End Sub If I shadows the event in the 485Specialized class it won't be raised unless I explicitly calls it from the Applications Form : AddHandler ctype(oSensor(0),c485Specialized).NewData, AddressOf oSensor_SensorData What I want is to raise the event in the derived class without having to ctype it. Is there something wrong with my hierarchy? Shouldn't the "Shadows" keyword shadow the base class procedures and let the derived classes handle the calls? I'm confused. Again :confused: Thank God it's Friday /Kejpa
  4. Alright, guess I'll have to be clearer on my subjects. Now that I've been convinced to use the new .NET IO I think I'll start all over in this thread http://www.xtremedotnettalk.com/showthread.php?p=419816 Thanks a bunch! /Kejpa
  5. Hi, I started out with a simple q about howto write a struct to a file but ended up remaking it all. Now I'm all .NET IO :-) Still some questions arise. I have one file that I want to write the following Struct Public Nodeid As Byte ' 1-127dec Public SyncTime As Single ' sec since midnight Public Value1 As Short ' +/-30000 Public Value2 As Short ' +/-30000 Public Value3 As Short ' +/-30000 from at least two separate objects. 1. How do I convert this struct to something that a BinaryWriter can write? 2. Who's the "best owner" of the file? Each object, the collection holding the objects or the application form/main ?!? Currently each object own its logfile, thus I can use a separate if I want and many objects can share one if I prefer that. But I'm having second thoughts. 3. The struct should be frequently added to the end of the file. Previously I managed that by having a Long at the first position telling where to write the next struct. Is this still the best approach? :confused: but smiling /Kejpa
  6. Monday and the rain is pouring down :) About your sample, There's no information about what record you're reading. Every call to the read function will render the same result, the first record, right? The load array (which don't seems to work) fetches the whole damn file, doesn't it? I need to be able to read each record one at a time and get the next the next time I call the function. The file will have at least two records written evey 300ms, so in a day there will be quite a few records to read... (I plan to keep each day in a separate file) I also need to have a customized header in the file. Readable for humans using "Notepad" to get some info on the system where the log is created. But I guess I can write it to the file in the sub where the file is created. Many thanx again /Kejpa
  7. Thanx Diverdan, I've gotten it to work, and for your comment on standards .... "Standards are great, everyone should have his." SeaU /Kejpa
  8. Thanx, I'll have a look at it on Monday. Now, week-end ;)
  9. Yes, I will read them back later, I keep each structure in it's own file so knowing which structure is stored is no problem. I'd love to use the new File functions but I haven't got them working yet. And I haven't got any good samples to follow. The files basically looks like this: pos 1-4. Next write pos (integer) pos 5-105 Fileinformation (string) pos 106- Saved structs Any help is appreciated :) /Kejpa
  10. Hi, In my application I want to make sure that all dateformats are like "2004-06-11" no matter what the user has set in his regional settings. I thought it would be easy just.... Application.CurrentCulture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd" but oh, no! This property is read-only. And creating a new one Dim ciMe As System.Globalization.CultureInfo = System.Globalization.CultureInfo.InvariantCulture() ciMe.DateTimeFormat = New System.Globalization.DateTimeFormatInfo() ciMe.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd" won't work either. Please help me out. /Kejpa
  11. Hi there, I have a general log-class which I use for logging a number of different structures. Public Sub Add2Log(ByVal LogItem As Object, Optional ByVal TimeStamp As Double = -1) '<snip> FilePutObject(iFilNr, LogItem, iWritePos) iWritePos += Len(LogItem) FilePut(iFilNr, iWritePos, 1) '<snip> End Sub One of the things I log is the following Struct Public Structure CanLoggFormat Public Nodid As Byte ' 1-127 Public SyncTime As Integer ' ms since OS started rollover every 49 days Public Value1 As Short ' +/-30000 Public Value2 As Short ' +/-30000 Public Value3 As Short ' +/-30000 End Structure When I try to write this to a file I get But if I try to change the line to FilePut(iFilNr, LogItem, iWritePos) it won't compile FYI, this is not the only Struct I plan to log. I might even try to log some class-object. That's why I used 'LogItem as Object' I stand as confused as a haytap between two donkeys Any suggestions? /Kejpa
  12. Create a new Project and copy the source code files using explorer. It usually works, the only problem I've ran into is when there are references in the source using fully qualified names (i.e. Assembly.module.procedure) HTH /Kejpa
  13. Sorry for bothering you with this... :o I've found it my self, it's working as I thought all the time, it's just that I was over writing a buffer and so I never got the request for model down to the external I/O. Changing that made it work swell The timestamp was 0 because it was never updated... Regards /Kejpa
  14. Hey there, I never found threading very hard until I tried accessing class level variables... :) Here's some stripped code for you Public Class Class1 ' Removed Private variables used for Property Get/Set Private imodModel As Integer ' External interface model Private rmodTimeStamp As Single ' Timestamp for updated data Private fThreadIsAlive As Boolean ' Flag for Reader thread loop Private baSensorProperties As System.Collections.BitArray = New System.Collections.BitArray(23) ' Property update flags Private tReader As Threading.Thread ' External reader thread Private oPropertyTimer As Threading.Timer ' Property reader thread Public Sub New() ' Created property reader thread oPropertyTimer = New Threading.Timer(New Threading.TimerCallback(AddressOf oPropertyTimer_OnTimer), 0, 10000, 30000) ' Created main IO reader in new thread tReader = New Threading.Thread(AddressOf Reader) fThreadIsAlive = True tReader.Start() End Sub Private Sub oPropertyTimer_OnTimer(ByVal Dummy As Object) Dim baCurrent As New BitArray(23) If Not Equals(baCurrent, baSensorProperties) Then ' Tell the world we've got some new properties for the IO RaiseEvent PropertyUpdate(Properties) End If End Sub Private Sub Reader() ' General IO reader thread Dim _data As cmsg ' Message structure Dim lRet As Integer = 0 ' General return recipient Dim data_len As Integer ' Lenght of received structure Do data_len = 1 Try lRet = ntdll.ReadIO(imodHandle, _data, data_len, 0) If lRet = 0 Then ' Receive Ok Dim iLen As Byte = _data.length And &H1F If ((iLen > 0) And (iLen <= 8)) Then ' Analyze received data DecodeSyncResult(_data.data) End If End If Catch err As Exception ' Just for development! Console.WriteLine(err.GetBaseException.ToString) End Try Loop While fThreadIsAlive End Sub Private Sub DecodeSyncResult(ByVal _Message() As Byte) ' Analyze message and update data Dim iRawValues(2), iReturnValues() As Integer iRawValues(0) = CInt(_Message(0)) + CInt(_Message(1)) * 256 iRawValues(1) = CInt(_Message(2)) + CInt(_Message(3)) * 256 iRawValues(2) = CInt(_Message(4)) + CInt(_Message(5)) * 256 iRawValues(2) = CInt(_Message(6)) + CInt(_Message(7)) * 256 Select Case imodModel ' Depending on the model different values will be exposed Case 10 ReDim iReturnValues(2) iReturnValues(0) = iRawValues(0) iReturnValues(1) = iRawValues(1) iReturnValues(2) = iRawValues(3) Console.WriteLine(iReturnValues(0) & vbTab & iReturnValues(1) & vbTab & iReturnValues(2)) Case 20 ReDim iReturnValues(1) iReturnValues(0) = iRawValues(0) iReturnValues(1) = iRawValues(3) Console.WriteLine(iReturnValues(0) & vbTab & iReturnValues(1)) Case Else End Select If Not iReturnValues Is Nothing Then ' Tell the world we've got new data and at what time we got it along with all properties of the object RaiseEvent NewData(iReturnValues, imodTimeStamp, Me) End If End Sub Protected Overrides Sub Finalize() ' Dispose all used objects If Not tReader Is Nothing Then fThreadIsAlive = False tReader.Abort() End If tReader = Nothing oPropertyTimer.Dispose() oPropertyTimer = Nothing End Sub End Class It's in the Reader sub when I was trying to get imodModel and imodTimestamp I stumbled over the problems with non-accessable variables. TIA /Kejpa
  15. Hi, I thought Threading was simple. Create a new thread which minds its own business. I never thought twice about it having its own variables... In my class I have a number of private variables as well as a few private threads (both common threads and timer threads). I want the threads and class to share the private variables. Shouldn't be too hard, IMHO.... Regards /Kejpa
  16. Sorry if I offended you. I was just surprised over the matters I pointed out. I will use (the modified) code and I'm thankful for what you've done. /Kejpa
  17. Hey DiverDan, does this really, really work?!?!? If mNumeric Then If m_bAltSort = True Then Return CLng(lv1.SubItems(mColumn).Text) + CDbl(lv2.SubItems(mColumn).Text) Else Return CDbl(lv2.SubItems(mColumn).Text) - CDbl(lv1.SubItems(mColumn).Text) End If Firstly, You're not comparing, you're adding/subtracting according to my universe. Secondly, If m_bAltSirt=true you're adding a Long with a double I'd have it this way If mNumeric Then If m_bAltSort = True Then Return CDbl(lv1.SubItems(mColumn).Text) > CDbl(lv2.SubItems(mColumn).Text) Else Return CDbl(lv2.SubItems(mColumn).Text) > CDbl(lv1.SubItems(mColumn).Text) End If [/codE] Another thing that might screw up is if you have text and numeric values in the same column, and the first is numeric. Then you will try to sort the listview as if the whole column was numeric and that won't work. Isn't it better to mark the column as numeric when you fill it? IMHO Kejpa
  18. Sorry, SortedList gives me a sorted list (surprise! ;) ) I want them /Kejpa
  19. Hi, PropertyCollection is a hash table wrapper, that's why it will not do for me. Try add five different items instead of one and then do a for each and print them. You will not get the same order as when you entered them. That's not satisfactory for me at least. Dim hash As Hashtable = New Hashtable() Dim itm As DictionaryEntry hash.Add("Port", CInt(1024)) hash.Add("Active", True) hash.Add("Protocol", True) hash.Add("Range", CDbl(700)) hash.Add("Bipolar", False) For Each itm In hash Console.WriteLine(itm.Key & "=" & itm.Value) Next Gives me this out put I'd like them in the order they were added. The ListDictionary does it for me. /Kejpa
  20. When displaying i.e. a Com-port I really want the Port# to be the first item and not the 15th. Using PropertyCollection gave me unpredicatble order of the properties, now when I'm using ListDirectory I get them in the order I added them in the class and thus I'm in control. (I like that ;)) /Kejpa
  21. Hi, what I want is something like the old PropertyBag. You put your values in the object one by one but you can also export them all by returning the bag. I made some tries with the PropertyCollection but it's not good, I want to extract the values in the same order as I entered them, the first added should be the first in a For Each loop. For the moment I'm using ListDictionary which seems to be doing what I want. /Kejpa
  22. Why not use the ListView. Initially somewhat more complex and harder to learn but when you're used to it it's simply wonderful /Kejpa
  23. It's a bad idea to use functions in the SQL-statements. Changing the database might ruin your code. I prefer using txtQty.text=MyRow.Item(2).ToString If the value in the table is null then it will be converted to '', if it's not you'll get the value as a string. Good luck /Kejpa
  24. Hi, I have a number of different collections that I need to show the properties of in a listview. My idea is to implement a "Properties" property where I can get the name and value of each property no matter what type of object the current one is. I've looked around a bit and found the "PropertyCollection" but no samples, have anyone tried it? Can I determine what properties should be visible through the collection? Any help or points of direction kindly accepted :) /Kejpa
×
×
  • Create New...