Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

vba - ADO Text Driver Trimming Leading Space -


i'm using adodb microsoft text driver parse text file in excel.

the problem lines of file have leading space, , leading space getting chopped.

when getstring(,1) on recordset, line like: " description not use"

gets trimmed to:

"description not use"

...this problematic because i'm parsing cisco config file, , leading space useful in figuring out if i'm still in same object or not.

for example text like:

object-group network abc_group  network-object host 192.10.24.71  network-object host 192.10.24.72  network-object host 192.10.24.20  network-object host 192.10.24.21 object-group network xyz_hosts  network-object host 192.10.24.55  network-object host 192.10.24.26 

...i using leading space tell me still in same object-group.

any ideas on how adodb keep leading space when reads text file?

i tried using filestreamobject, discovered file reading had lines ending in chr(13) , ending in both chr(13) , chr(10), throwing off readline method.

sorry, earlier version of answer used c#. vba, have little more heavy lifting.

if file small enough fit in memory, read whole thing in string, , split it:

private function splitfilecontents(byval filecontents string) string()      dim arrresult() string     dim resultcount long     dim crpos long     dim lfpos long     dim endpos long      while len(filecontents) > 0         crpos = instr(filecontents, vbcr)         lfpos = instr(filecontents, vblf)          if crpos = 0 , lfpos = 0             redim preserve arrresult(0 resultcount)             arrresult(resultcount) = filecontents             resultcount = resultcount + 1             exit         elseif crpos = 0             endpos = lfpos         elseif lfpos = 0             endpos = crpos         elseif crpos < lfpos             endpos = crpos         else             endpos = lfpos         end if          if endpos > 1             redim preserve arrresult(0 resultcount)             arrresult(resultcount) = left$(filecontents, endpos - 1)             resultcount = resultcount + 1         end if          if endpos = len(filecontents)             filecontents = ""         else             filecontents = mid$(filecontents, endpos + 1)         end if     loop      if resultcount = 0         redim arrresult(0 0)         arrresult(0) = ""     end if      splitfilecontents = arrresult end function 

alternatively, there several possible approaches using fixed-width format, preserve leading spaces. these articles discuss using schema.ini file specify fixed-width file format:

http://support.microsoft.com/kb/187670

http://office.microsoft.com/en-us/access-help/initializing-the-text-data-source-driver-hp001032166.aspx


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -