Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using TAB as CSV delimiter
Hi guys,
What's the difference between to two vbConstants: - vbTab - Chr(9) and - vbKeyTab - Chr(57) Which one will be the most corrent to use as delimiter in a .CSV file? Thanks, CE --- Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret. http://www.avast.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using TAB as CSV delimiter
Hi guys,
What's the difference between to two vbConstants: - vbTab - Chr(9) and - vbKeyTab - Chr(57) Which one will be the most corrent to use as delimiter in a .CSV file? Thanks, CE --- Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret. http://www.avast.com Hi Charlotte, I've always used vbTab and so can vouch that it works reliably. I'm not familiar with vbKeyTab and so can't speak to its usage in place of vbTab. -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using TAB as CSV delimiter
GS wrote:
What's the difference between to two vbConstants: - vbTab - Chr(9) and - vbKeyTab - Chr(57) Which one will be the most corrent to use as delimiter in a .CSV file? Hi Charlotte, I've always used vbTab and so can vouch that it works reliably. I'm not familiar with vbKeyTab and so can't speak to its usage in place of vbTab. vbTab is correct, because that's the ASCII code for the tab character. (Chr(57) = "9".) vbKeyTab is the scan code for pressing the Tab key on the keyboard (a completely unrelated task), largely used in forms, like this: Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If vbKeyTab = KeyAscii Then MsgBox "Tab" End Sub -- [Gerald] Ford had only one major fault -- he was too nice a guy. -- Bob Hartman, Ford's speechwriter |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using TAB as CSV delimiter
GS wrote:
What's the difference between to two vbConstants: - vbTab - Chr(9) and - vbKeyTab - Chr(57) Which one will be the most corrent to use as delimiter in a .CSV file? Hi Charlotte, I've always used vbTab and so can vouch that it works reliably. I'm not familiar with vbKeyTab and so can't speak to its usage in place of vbTab. vbTab is correct, because that's the ASCII code for the tab character. (Chr(57) = "9".) vbKeyTab is the scan code for pressing the Tab key on the keyboard (a completely unrelated task), largely used in forms, like this: Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If vbKeyTab = KeyAscii Then MsgBox "Tab" End Sub Thanks! That makes sense since KeyAscii would be the right place for using vbKey<whateve because we would be testing a keyboard action! I'm not familiar with vbKeyTab because the only keyboard action I test for is when the ESC key is pressed, and I always use the numeric value rather than the VB constant. Also, vbTab is a printable string character and so makes sense that it would be used for delimiting a string!<g -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using TAB as CSV delimiter
GS wrote:
GS wrote: What's the difference between to two vbConstants: - vbTab - Chr(9) and - vbKeyTab - Chr(57) Which one will be the most corrent to use as delimiter in a .CSV file? Hi Charlotte, I've always used vbTab and so can vouch that it works reliably. I'm not familiar with vbKeyTab and so can't speak to its usage in place of vbTab. vbTab is correct, because that's the ASCII code for the tab character. (Chr(57) = "9".) vbKeyTab is the scan code for pressing the Tab key on the keyboard (a completely unrelated task), largely used in forms, like this: Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If vbKeyTab = KeyAscii Then MsgBox "Tab" End Sub Thanks! That makes sense since KeyAscii would be the right place for using vbKey<whateve because we would be testing a keyboard action! I'm not familiar with vbKeyTab because the only keyboard action I test for is when the ESC key is pressed, and I always use the numeric value rather than the VB constant. vbKey<X is useful for avoiding magic numbers. Writing your code now, you know that 27 is Escape (or whatever), but a month from now? A year? Unless you normally carry those values in your head, it's best IMO to use the constants. Also, vbTab is a printable string character and so makes sense that it would be used for delimiting a string!<g Yeah, precisely. Upon reviewing the docs, it looks like vbKeyTab = 9, not 57 as Charlotte posted. Not entirely sure where that number came from. Maybe the scan codes are different for non-US keyboards, I dunno. -- Is my phone number 1-800-DO-MY-JOB? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using TAB as CSV delimiter
vbKey<X is useful for avoiding magic numbers. Writing your code now,
you know that 27 is Escape (or whatever), but a month from now? A year? Unless you normally carry those values in your head, it's best IMO to use the constants. Yeah, you make a valid point! Yes, the ESC key # is 27 and since it's the only one I use it's easy to remember. However, I do feel that using the constant makes code more self-documenting and so I should change my habits to that end. And yes, you're correct that vbKeyTab = KeyAscii(9)! -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using TAB as CSV delimiter
GS wrote:
vbKey<X is useful for avoiding magic numbers. Writing your code now, you know that 27 is Escape (or whatever), but a month from now? A year? Unless you normally carry those values in your head, it's best IMO to use the constants. Yeah, you make a valid point! Yes, the ESC key # is 27 and since it's the only one I use it's easy to remember. However, I do feel that using the constant makes code more self-documenting and so I should change my habits to that end. I strongly recommend it -- but OTOH, in some of my old VB6 projects, I used various keys in such a way that it was common to see something like this: Select Case KeyCode Case vbKeyTab Case vbKeyLeft Case Asc("W") End Select -- Power... immense power, so absolute... |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using TAB as CSV delimiter
GS wrote:
vbKey<X is useful for avoiding magic numbers. Writing your code now, you know that 27 is Escape (or whatever), but a month from now? A year? Unless you normally carry those values in your head, it's best IMO to use the constants. Yeah, you make a valid point! Yes, the ESC key # is 27 and since it's the only one I use it's easy to remember. However, I do feel that using the constant makes code more self-documenting and so I should change my habits to that end. I strongly recommend it -- but OTOH, in some of my old VB6 projects, I used various keys in such a way that it was common to see something like this: Select Case KeyCode Case vbKeyTab Case vbKeyLeft Case Asc("W") End Select I started using this line in the _Keypress event on forms... If KeyAscii = 27 Then Unload Me 'Esc ...as the default in my form template, which was formatted for font and had the basic Ok/Cancel buttons placed. I just did copy/paste to insert the line in other _Keypress events. As of now the form template has been modified as follows. If KeyAscii = vbKeyEscape Then Unload Me -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using TAB as CSV delimiter
Hi Guys,
Sorry for a late reply, but I've been away for a few days :-) But, thank you for your replys - everything makes sense now :-) CE "Charlotte E." wrote in message ... Hi guys, What's the difference between to two vbConstants: - vbTab - Chr(9) and - vbKeyTab - Chr(57) Which one will be the most corrent to use as delimiter in a .CSV file? Thanks, CE --- Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret. http://www.avast.com --- Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret. http://www.avast.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
TTC delimiter restriction | Excel Discussion (Misc queries) | |||
CSV - no delimiter at end of line | Excel Discussion (Misc queries) | |||
delimiter | Excel Programming | |||
Text to Row by Delimiter | Excel Programming | |||
Tab Delimiter File | Excel Discussion (Misc queries) |