R
ravisispal
Guest
Hi there,
I am finishing the commissioning program for an alarm system I am prototyping. I have actually finished the prototype, yet I cannot bring an end to this VB.net program!
I have a datagridview (Sounder_GroupsDataGridView) which is populated by an XML file before the form opens. The DataGridView (Sounder_GroupsDataGridView) has 34 columns and 12 set rows as shown in the photo below HOWEVER there is one column after the "signal" column containing a "location" column which is hidden.
Columns: Signal | Location | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | >all the way to> | 32 |
What I want to do is export:
| Location | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | >all the way to> | 32 |
The file needs to be laid out as follows. So its location with a comma and then the number values from the 32 checkboxes for that row. But I need to append 32 "F" characters because my system needs 64 characters per line. So, a finished line will look like:
0,
01010101010101000000000101010101
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF64,01010101010101000000000101010101FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
128,00000010101010101001010101010101FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
192,10101010101011111111111111111111FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
256,10101010101011111111111111111111FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
...continued...
I have previously asked how to export two specific columns to a text file, but am unable to modify this to write the additional 31 columns. I have been able to successfully export two columns with that code from the sounder_groupsDataGridView. Heres that code:
The problem with this code is that if I dont manually check the boxes, I will get "true" or "false" as opposed to the numerical value which I need.
Dim sLine As String = ""
Dim sLines As String = "" added
For iRow As Integer = 0 To Sounder_Groups.Sounder_GroupsDataGridView.RowCount - 1
sLine = ""
For iCol As Integer = 0 To Sounder_Groups.Sounder_GroupsDataGridView.ColumnCount - 1
If iCol = 1 Or iCol = 2 Then
sLine &= Sounder_Groups.Sounder_GroupsDataGridView(iCol, iRow).Value.ToString & ","
End If
Next
sLines &= sLine.Substring(0, sLine.Length - 1) & vbCrLf
Next
My.Computer.FileSystem.WriteAllText("C:\testexport.txt", sLines, False) generated from right click, snippets
Dim sLines As String = "" added
For iRow As Integer = 0 To Sounder_Groups.Sounder_GroupsDataGridView.RowCount - 1
sLine = ""
For iCol As Integer = 0 To Sounder_Groups.Sounder_GroupsDataGridView.ColumnCount - 1
If iCol = 1 Or iCol = 2 Then
sLine &= Sounder_Groups.Sounder_GroupsDataGridView(iCol, iRow).Value.ToString & ","
End If
Next
sLines &= sLine.Substring(0, sLine.Length - 1) & vbCrLf
Next
My.Computer.FileSystem.WriteAllText("C:\testexport.txt", sLines, False) generated from right click, snippets
Would really love some help on this. I have no idea how to proceed.
Really wish these things were simpler to use. They have been the bane of my life.
Continue reading...