给定一字符串 例如pre1 返回的内容要是pre2 也就是最后一个一个数字加一
当给定pre9时 要返回pre11。就是这样pre1.....pre9,pre11,pre12.....pre19

解决方案 »

  1.   

    每次检查I是否为10,如果I为10,则I等于1,然后"pre"+I
    因为string+int=string
      

  2.   

    private function ChangStr(byval isStr as string) as string
     return "pre" & (val(replace(istr,"pre",""))+1)
    end function
      

  3.   

    很简单啊,取出最后一位,以及最后的数字。
    如果最后一位为9则,新的字符串为pre & 最后的数字+2
    如果最后一位不为9则,新的字符串为pre & 最后的数字+1
    str="pre……";str1=mid(str,3,len(str))
    str2=mid(str,len(str)-1,len(str))
    if int(str2)<>9 then str="pre" & Str$(int(str1)+1)
    else str="pre" & Str$(int(str)+2)
      

  4.   

    dim strA as string
    dim intTmp as integer
    dim StrB as stringstrA="pre1"
    ...
    intTmp=val(mid(strA,4))+1
    if intTmp mod 10=0 then inttmp=intTmp+1
    strB="pre" & intTmp
      

  5.   

    Public Function ChangStr(ByVal Str As String) As String
    Dim str1 As String
    Dim str2 As Stringstr1 = Mid(Str, 3, Len(Str))
    str2 = Mid(Str, Len(Str) - 1, Len(Str))
    If Int(str2) <> 9 Then Str = "pre" & Str$(Int(str1) + 1)
    Else
    Str = "pre" & Str$(Int(Str) + 2)
    End If
    ChangStr = Str
    End Function
     
    这段代码写好 为什么会出错:“缺少数组”
      

  6.   

    Public Function ChangStr(ByVal iStr As String) As StringChangStr = "pre" & Trim(Str((IIf((Val(Replace(iStr, "pre", "")) + 1) Mod 10 = 0, Val(Replace(iStr, "pre", "")) + 2, Val(Replace(iStr, "pre", "")) + 1))))End Function
      

  7.   

    我觉得他想表述的是。
    dim pre1 as string 
    dim pre2 as string
    ......
    这种情况吧。
    如果输入的为pre1这个字串,则返回pre2这个字串。
    ......
    不然太容易了。