我找不到错误 [英] I can not find the error

查看:86
本文介绍了我找不到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

计数不能低于零。

i得到此错误,如果有人可以帮助我,我无法解决!



"Count cannot be less than zero."
i get this error and i can not resolve please if somebody can help me!

Dim encoding__1 As Encoding = Encoding.GetEncoding("windows-1251")
           If File.Exists(Me.TextFile) Then
               File.Delete(Me.TextFile)
           End If
           Dim streamWriter As New StreamWriter(Me.TextFile, False, encoding__1)
           streamWriter.Write(" 01" & vbTab & "1" & vbTab & vbTab & "0" & vbTab & vbCr & vbLf)
           Dim num1 As Integer = 0
           Dim enumerator As List(Of Article).Enumerator
           Try
               enumerator = Me.Stavki.GetEnumerator()
               While enumerator.MoveNext()
                   Dim current As Article = enumerator.Current
                   Strings.Chr(CInt(current.VAT))
                   Dim num2 As Short = CShort(1)
                   Select Case current.VAT
                       Case VATgroup.А
                           num2 = CShort(1)
                           Exit Select
                       Case VATgroup.Б
                           num2 = CShort(2)
                           Exit Select
                       Case VATgroup.В
                           num2 = CShort(3)
                           Exit Select
                       Case VATgroup.Г
                           num2 = CShort(4)
                           Exit Select
                   End Select
                   If num1 Mod 2 = 0 Then
                       streamWriter.Write(String.Format("#1{0}" & vbTab & "{3}" & vbTab & "{1}" & vbTab & "{2}" & vbTab & "0" & vbTab & vbTab & vbTab, DirectCast(current.Name.Remove(20, current.Name.Length - 20), Object), DirectCast(Me.FormatNumber(current.Price, 2), Object), DirectCast(Me.FormatNumber(current.Amount, 3), Object), DirectCast(num2, Object)) + vbCr & vbLf) ' ERROR IS HERE
                   Else
                       streamWriter.Write(String.Format(" 1{0}" & vbTab & "{3}" & vbTab & "{1}" & vbTab & "{2}" & vbTab & "0" & vbTab & vbTab & vbTab, DirectCast(current.Name.Remove(20, current.Name.Length - 20), Object), DirectCast(Me.FormatNumber(current.Price, 2), Object), DirectCast(Me.FormatNumber(current.Amount, 3), Object), DirectCast(num2, Object)) + vbCr & vbLf)
                   End If
                   num1 += 1

               End While
           Finally
               enumerator.Dispose()
           End Try
           streamWriter.Write(String.Format("&5{0}" & vbTab & vbTab, DirectCast(PaidMode, Object)) + vbCr & vbLf)
           streamWriter.Write("%8")
           streamWriter.Flush()
           streamWriter.Close()

推荐答案

显然,(current.Name.Length - 20)产生一个小于零的值!

查看 String.Remove [ ^ ]方法......
Obviously, (current.Name.Length - 20) yields a less then zero value!
See the possible errors of String.Remove[^] method...


这篇关于我找不到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆