如果是SQL Server:
cmd.CommandText = "Select MAX(单号) As 最大单号 FROM 内部表 where substring(单号,5,1) = ' " & Vars("单种") & " ' "