使用“打印”将格式化文本写入文件

我在VBAmacros的工作表中创build了输出string,并试图使用Print打印每行文本文件,预期的输出如下所示:

class A { public: UINT8 tbcDatabaseValidSpecialFunc; TbcDatabaseCycleDefTable tbcDatabaseCycleDefTable[MAX_CONFIG_TBC_DATABASE_CYCLE_DEF]; UINT8 MiscEthernetSpeed; }; 

问题:如何使用Print打印A类内部的alignment列? 喜欢这个:

 output_string = var_type + var Print #textfile, output_string 

var_type(第一列)的长度是变体,如何alignmentvar(第二列)?

非常感谢!

var_type有最大长度吗? 如果是,那么使用例如Space()填充它可能会导致固定的列宽(以每列固定数量的字符为单位):

 Const cColumnChars as Integer = 20 output_string = var_type & Space(cColumnChars - Len(var_type)) & var 

注意:如果var_type是数字,那么Format()可能有助于使其变成形状。