Passing structures of structures into functions/subs
Posted: 10 January 2009, 13:10 PM
Hi
In the last 2 lines of the following code, I dont understand what Im doing wrong ? The commented out line (last line) creates the error message which is commented above the it. If I change it to the code above then its fine, but I didnt want to define extra variables and write the extra code if I dont have to.
This must be a syntax thing or something Im missing
Neil
In the last 2 lines of the following code, I dont understand what Im doing wrong ? The commented out line (last line) creates the error message which is commented above the it. If I change it to the code above then its fine, but I didnt want to define extra variables and write the extra code if I dont have to.
Code: Select all
public function enforceLeadingZero(byval i as Byte) as String
if (i < 10) then
enforceLeadingZero = "0" & i
else
enforceLeadingZero = CStr(i)
end if
end function
public function myTimeToString(byVal t as MyTime, byval showSeconds as Boolean = false) as String
Dim h as String
Dim m as String
Dim s as String
h = enforceLeadingZero(t.hour)
m = enforceLeadingZero(t.minute)
myTimeToString = h & ":" & m
if (showSeconds) then
s = enforceLeadingZero(t.seconds)
myTimeToString = myTimeToString & ":" & s
end if
end function
public function myDateToString(byVal da as MyDate) as String
Dim y as String
Dim m as String
Dim d as String
y = enforceLeadingZero(CByte(da.year))
m = enforceLeadingZero(da.month)
d = enforceLeadingZero(da.day)
myDateToString = d & "/" & m & "/" & y
end function
public function timeStampToString(byval ts as MyTimeStamp) as String
Dim tt as Mytime = ts.ttime
Dim td as MyDate = ts.tdate
timeStampToString = myDateToString(td) & " " & myTimeToString(tt)
' The following line gives compiler error
' Error: function "myDateToString", type conflict parameter 1,
' formal:Struct MyDate, actual:Structure
' timeStampToString = myDateToString(ts.tdate) & " " & myTimeToString(ts.ttime)
end function
Neil