הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Friday, July 26, 2019 5:10 AM
Heres a picture of the code,
I dont know what to do.
Public Sub Login()
Dim index As Integer = 0
While index < Combos.Count
Dim str() As String = Combos(index).Split(" - $")
Dim money As Integer
money = Val(str(1))
If money > 24.99 Then
Dim IT As New ListViewItem
IT.Text = str(0)
IT.SubItems.Add(str(1))
ListView1.Items.Add(IT)
ElseIf money < 25.0 Then
Label2.Text = money
End If
Label1.Text += 1
index += 1
End While
End Sub
I want to make it to check the file first part and second part i already split the file.
The file looks like this: 28246000013193 - $0.87
All replies (7)
Friday, July 26, 2019 5:49 AM
Hi,
'Index was outside the bounds of the array.',I don't know which code reported this error,but But you can make a judgment,for example
Dim money As Integer
If str.Count > 1 Then
money = Val(str(1))
Else
MsgBox("error")
End If
Best Regards,
Alex
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Friday, July 26, 2019 7:22 AM
Probably you should fix this line too:
* Dim str( ) As String = Combos( index).Split( {" - $"}, StringSplitOptions.None)*
Tuesday, July 30, 2019 2:40 AM
Hi Erik,
Try it with a FOR NEXT loop like this.
>>
Public Class Form1
Private combos() As String = {"28246000013193", " - ", "$", "0.87"}
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For index As Integer = 0 To combos.GetUpperBound(0)
MessageBox.Show(combos(index))
Next
End Sub
End Class
I've sometimes found that a WHILE loop can in that manner can give you an index error.
Regards,
John
Regards, ![]()
Click this link to see the NEW way of how to insert a picture into a forum post.
App Hub for Windows Phone & XBOX 360 developers.
Tuesday, July 30, 2019 3:28 AM
Dim str() = Combos(index).Split(" - $")
Dim money = CDec(str(1))
Success
Cor
Tuesday, July 30, 2019 3:35 AM
Dim str() = Combos(index).Split(" - $") Dim money = Dec(str(1))
Success
Cor
Hi Cor,
Did you mean? >>
Dim str() = Combos(Index).Split(" - $")
Dim money = CDec(str(1))
'or
Dim someMoney = Convert.ToDecimal(str(1))
;-)
How are you by the way?
Reagrds,
John.
Regards, ![]()
Click this link to see the NEW way of how to insert a picture into a forum post.
App Hub for Windows Phone & XBOX 360 developers.
Tuesday, July 30, 2019 8:22 AM
John thanks for showing my mistake.
I guess you are very happy because soon England is not any more among us Europeans?
Success
Cor
Wednesday, July 31, 2019 12:14 AM
I guess you are very happy because soon England is not any more among us Europeans?
Success
Cor
Hi again Cor,
It depends on how the economy of the country goes really.
I don't have much enthusiam with our current PRIME MINISTER.
Regards,
John
Regards, ![]()
Click this link to see the NEW way of how to insert a picture into a forum post.