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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Then Else from Crystal syntax to Basic syntax

Status
Not open for further replies.

DJWheezyWeez

Technical User
Jun 5, 2008
265
US
I've mostly got what I need but I'm having trouble translating a formula from crystal syntax to basic syntax.

The code below gives me a string like 180403 which is a YYMMDD format for the current day and uses if statements to include a 0 when the month or day number is a single digit.
Code:
shared stringvar DataToEncode := (right(replace(replace(cstr(year(today)),".00",""),",",""),2)) & (if len(replace(cstr(month(today)),".00","")) = 1 then "0" & replace(cstr(month(today)),".00","") else replace(cstr(month(today)),".00","")) & (if len(replace(cstr(day(today)),".00","")) = 1 then "0" & replace(cstr(day(today)),".00","") else replace(cstr(day(today)),".00",""));

The problem I'm having comes when trying to adapt this to basic syntax, specifically with the if statement (or at least that's where the error comes up). The code below works after I've taken out the if statements but I'm having trouble finding the right syntax for the if.
Code:
Dim DataToEncode as String
DataToEncode = (right(replace(replace(cstr(year(today)),".00",""),",",""),2))

Is there a better way to go about this or can someone help me with the correct basic syntax?

Thanks.
 
Hi,
Code:
DataToEncode = Format(Date, "yymmdd")

I assume you’re referring to BASIC...
Beginner’s
All-purpose
Symbolic
Instruction
Code

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
I sure did not remember what BASIC stood for (I first used it in the mid 1970's). :)
 
I too, on a DEC system, TTY I/O.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top