Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying unsuccessfully to compare/replace a tab!

Status
Not open for further replies.

treyball3

Programmer
Jun 20, 2001
74
US
I'm reading a record from an access database. In one record, I have some tab and carriage return delimited information. Specifically, Name<tab>Address<return>Name<tab>Address<return> etc. Well, I'm then using that data to merge into a word document, so I needed to add formatting. So, now it looks like this... Name<tab>Address<return><tab><tab>Name<tab>Address<return>. When trying to populate back into the datagrid, I first split on the CrLf and then on the Tab. Well, after doing that my first character of my second line is a tab. I want to skip that in my processing. I've tried multiple ways of skipping, but to no avail.

Code:
sRows = sData.Split(vbCrLf)
        For Each sTemp In sRows
            sColumns = sTemp.Split(vbTab)
            i = 0
            dgViewRow = New DataGridViewRow
            dgViewRow.CreateCells(dbDataGrid)
            For Each sTemp2 In sColumns
                sTemp2 = Replace(sTemp2, ControlChars.Tab, "")
                If sTemp2 <> vbTab Then
                    dgViewRow.Cells(i).Value = sTemp2
                    i += 1
                End If
            Next
            dbDataGrid.Rows.Add(dgViewRow)
        Next

I've tried
Code:
If sTemp2 <> controlchars.tab
Code:
If cchar(sTemp2) <> controlchars.tab
Code:
If sTemp2 <> vbTab
Code:
If cchar(sTemp2) <> vbTab
Code:
If sTemp2 <> chr(9)
Code:
replace(stemp2, vbTab, "")
and so on.

sTemp2 is a square in quotes... so is vbTab. I'm not sure what else to try.



Thanks - Todd
 
I figured it out. I was assuming it was a tab. I had also tried comparing it against vbCrLf. But, as it turns out, it was just a vbLf. oof!



Thanks - Todd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top