[英]VB6 to c# code LSet Mid
我试图将VB6代码转换为C#,并希望了解LSet和Mid,下面是我的vb6和C#代码,转换是否正常
strPrint = ""
strPAD = Space(12)
LSet strPAD = Mid(Trim(rsVoucher.Fields("Reference")) & "", 1, 12)
strPrint = strPrint & strPAD & " " ' 13
string reference = vouchDr["REFERENCE"].ToString();
string temp_reference = reference;
if (reference.Length > 12)
{
temp_reference = reference.Substring(0, 12) + "";
}
strPAD = temp_reference + (new string(' ', 12 - temp_reference.Length));
strPrint = strPAD + " "; //13
您正在寻找:'PadLeft'字符串对象的方法。
您的代码看起来像....
string temp_reference = reference.PadLeft(12, ' ');
if (temp_reference.Length > 12)
{
temp_reference = temp_reference.Substring(0, 12) + "";
}
temp_reference += " ";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.