I have begun my adventure into using and understanding VBA in Access with a simple task: Parsing a text string with carriage returns, semicolons, and several other characters.
I am using the Immediate window in Access 2010 as my test bed, in a manner similar to the irb (interactive ruby console) that Ruby uses.
I have written the following code:
<begin code snippet>
input_string="04.20.2012; Rx TO DOSE WARFARIN ; ORDERING MD= bubba, K ;
NOTES: 0n 2 mg daily ;
INDIC= A-FIB ; GOAL INR= 2-3 ; RPH=lv;
=======================================
04.20.2012 INR= 3.0; DOSE = 0 MG; RPH=zz
04.21.2012 INR= 1.9; DOSE = 1 MG; RPH=aa
04.22.2012 INR= 2.5; DOSE=2.5 MG ; RPH=bb
04.23.2012 INR= 2.3; DOSE=3 MG ; RPH=bbl
04.24.2012 INR=2.3 ; DOSE =4MG ; RPH=dd"
' functions
'0th Step
'cleans input_string
input_string=replace(input_string,Chr(10),"") 'removes new lines
input_string=replace(input_string,Chr(13),"") 'removes carriage returns
input_string=replace(input_string,Chr(59),"") 'removes semicolons
input_string=replace(input_string,Chr(61),"") 'removes equals signs
input_string=replace(input_string,Chr(45),"") 'removes minus signs
? input_string
<end code snippet>
I have tested bits and pieces of the string, and from what I have read in various forums, this should give me one long string with the specified characters removed, but when I enter the ? input_string command, the Immediate window just gives me a blank line.
I am not worried about DRY or style at this point, but rather just getting the hang of syntax.
Any help would be appreciated.
Thank you.
I am using the Immediate window in Access 2010 as my test bed, in a manner similar to the irb (interactive ruby console) that Ruby uses.
I have written the following code:
<begin code snippet>
input_string="04.20.2012; Rx TO DOSE WARFARIN ; ORDERING MD= bubba, K ;
NOTES: 0n 2 mg daily ;
INDIC= A-FIB ; GOAL INR= 2-3 ; RPH=lv;
=======================================
04.20.2012 INR= 3.0; DOSE = 0 MG; RPH=zz
04.21.2012 INR= 1.9; DOSE = 1 MG; RPH=aa
04.22.2012 INR= 2.5; DOSE=2.5 MG ; RPH=bb
04.23.2012 INR= 2.3; DOSE=3 MG ; RPH=bbl
04.24.2012 INR=2.3 ; DOSE =4MG ; RPH=dd"
' functions
'0th Step
'cleans input_string
input_string=replace(input_string,Chr(10),"") 'removes new lines
input_string=replace(input_string,Chr(13),"") 'removes carriage returns
input_string=replace(input_string,Chr(59),"") 'removes semicolons
input_string=replace(input_string,Chr(61),"") 'removes equals signs
input_string=replace(input_string,Chr(45),"") 'removes minus signs
? input_string
<end code snippet>
I have tested bits and pieces of the string, and from what I have read in various forums, this should give me one long string with the specified characters removed, but when I enter the ? input_string command, the Immediate window just gives me a blank line.
I am not worried about DRY or style at this point, but rather just getting the hang of syntax.
Any help would be appreciated.
Thank you.