Posts

Showing posts from November, 2004

#define variable arguments

Since #define does not take variable arguments you have to work around using function pointers. void __format_out(const char* fmt, ...); typedef void (*ptr2Fn) (const char* fmt, ...) ; ptr2Fn _storeLine(int nSeverity,int lineNumber,char* fileName); #define CTRACE _storeLine(40,__LINE__,__FILE__) ----------------------- ptr2Fn _storeLine(int nPSeverity,int nPlineNumber,char* szPfileName) { nSeverity = nPSeverity; nlineNumber=nPlineNumber; szfileName = (char*)szPfileName; return __format_out; } ----------------------- inline void __format_out(const char * fmt, ...) { CString ___str; va_list marker; va_start(marker, fmt); USES_CONVERSION; ___str.FormatV(A2T(fmt), marker); va_end(marker); } TRACE("nUMBER IS %d",223);

vba code for iterating through colums

Private Sub CommandButton1_Click() CalculateAndDispalyDifference End Sub Sub CalculateAndDispalyDifference() Dim t1, t2 As Date For counter = 2 To 91 t1 = Worksheets("Sheet1").Cells(counter, 4).Value t2 = Worksheets("Sheet1").Cells(counter + 1, 4).Value If t2 > t1 Then Worksheets("Sheet1").Cells(counter, 6).Value = t2 - t1 Else Worksheets("Sheet1").Cells(counter, 6).Value = t1 - t2 End If counter = counter + 1 Next counter End Sub

VBA xode snippet for iterating through colums

Private Sub CommandButton1_Click() CalculateAndDispalyDifference End Sub Sub CalculateAndDispalyDifference() Dim t1, t2 As Date For counter = 2 To 91 t1 = Worksheets("Sheet1").Cells(counter, 2).Value //.Cells(row,column) t2 = Worksheets("Sheet1").Cells(counter, 4).Value If t2 > t1 Then Worksheets("Sheet1").Cells(counter, 5).Value = t2 - t1 Else Worksheets("Sheet1").Cells(counter, 5).Value = t1 - t2 End If Next counter End Sub