منتديات طرب عراق




إضافة رد
 
أدوات الموضوع انواع عرض الموضوع
قديم 05-06-2012, 08:50 PM   المشاركة رقم: 1
المعلومات
الكاتب:
اللقب:
الرتبة


البيانات
التسجيل: Feb 2011
العضوية: 14367
المشاركات: 18,682 [+]
بمعدل : 11.30 يوميا
اخر زياره : [+]
معدل التقييم: 23
نقاط التقييم: 10
الملك الراقي is on a distinguished road

التوقيت

الإتصالات
الحالة:
الملك الراقي غير متواجد حالياً
وسائل الإتصال:

Loop Problems
Having a lot of Problems with a for Loop I have written. with the following code, the it only finds the item if it is top of the list. ie in the following example, it finds jim but not jack, james or peter. Any help would be very much appreciated and I'm sure its something simple note, on the form there are two listboxes (lstbox_items, lstbox_log), two buttons (btn_test, btn_loaditems) and one openfiledialog the code is as follows and there is also a **** file to load which is simply Code: --------- jim jack james peter --------- Code: --------- Imports System.Net Imports System.****.RegularExpressions Imports System.IO Imports System.**** Imports System.IO.Compression Imports System.Threading Imports System.******s.Forms Public Class Form1 Private testthread As Thread Dim streamer As IO.StreamReader Dim TestSource As String Dim CurrentTime As String Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles My****.Load Control.CheckForIllegalCrossThreadCalls = False End Sub Private Sub btn_loaditems_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_loaditems.Click OpenFileDialog1.ShowDialog() Dim itemlist******** = OpenFileDialog1.File**** streamer = IO.File.Open****(itemlist********) Dim mystring() As String = streamer.ReadToEnd.Split(vbNewLine) lstbox_items.Items.AddRange(mystring) End Sub Private Sub btn_test_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_test.Click testthread = New Threading.Thread(AddressOf test) testthread.IsBackground = True testthread.Start() End Sub Private Sub test() Dim items As String = "jim, jack, james, peter" Dim count = lstbox_items.Items.Count - 1 For i = 0 To count Dim currentitem = GetListboxItem(lstbox_items, i) If items.Contains(currentitem) Then lstbox_log.Items.Add("found " & currentitem) Else lstbox_log.Items.Add("not found " & currentitem) End If Next End Sub Private Function GetListboxItem(ByVal MyControl As System.******s.Forms.ListBox, ByVal index As Integer) As String Dim **** As String If MyControl.InvokeRequired Then Dim args As Object() = {MyControl, index} **** = (MyControl.Invoke(New GetListboxItemInvoker(AddressOf GetListboxItem), args)) Else **** = MyControl.Items.Item(index) End If Return **** End Function ---------

Having a lot of Problems with a for Loop I have written. with the following code, the it only finds the item if it is top of the list. ie in the following example, it finds jim but not jack, james or peter. Any help would be very much appreciated and I'm sure its something simple

note, on the form there are two listboxes (lstbox_items, lstbox_log), two buttons (btn_test, btn_loaditems) and one openfiledialog

the code is as follows and there is also a **** file to load which is simply
Code:
jim
jack
james
peter
Code:
Imports System.Net
Imports System.****.RegularExpressions
Imports System.IO
Imports System.****
Imports System.IO.Compression
Imports System.Threading
Imports System.******s.Forms

Public Class Form1

Private testthread As Thread
Dim streamer As IO.StreamReader
Dim TestSource As String
Dim CurrentTime As String

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles My****.Load
Control.CheckForIllegalCrossThreadCalls = False
End Sub


Private Sub btn_loaditems_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_loaditems.Click
OpenFileDialog1.ShowDialog()
Dim itemlist******** = OpenFileDialog1.File****
streamer = IO.File.Open****(itemlist********)
Dim mystring() As String = streamer.ReadToEnd.Split(vbNewLine)
lstbox_items.Items.AddRange(mystring)
End Sub
Private Sub btn_test_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_test.Click
testthread = New Threading.Thread(AddressOf test)
testthread.IsBackground = True
testthread.Start()
End Sub
Private Sub test()
Dim items As String = "jim, jack, james, peter"
Dim count = lstbox_items.Items.Count - 1
For i = 0 To count
Dim currentitem = GetListboxItem(lstbox_items, i)
If items.Contains(currentitem) Then
lstbox_log.Items.Add("found " & currentitem)
Else
lstbox_log.Items.Add("not found " & currentitem)
End If
Next
End Sub
Private Function GetListboxItem(ByVal MyControl As System.******s.Forms.ListBox, ByVal index As Integer) As String
Dim **** As String
If MyControl.InvokeRequired Then
Dim args As Object() = {MyControl, index}
**** = (MyControl.Invoke(New GetListboxItemInvoker(AddressOf GetListboxItem), args))
Else
**** = MyControl.Items.Item(index)
End If
Return ****
End Function










عرض البوم صور الملك الراقي   رد مع اقتباس

منتديات طرب عراق

إضافة رد

مواقع النشر (المفضلة)

أدوات الموضوع
انواع عرض الموضوع

تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة
Trackbacks are متاحة
Pingbacks are متاحة
Refbacks are متاحة


المواضيع المتشابهه
الموضوع كاتب الموضوع المنتدى مشاركات آخر مشاركة
loop... الملك الراقي المواضيع المحذوفه والمكرره 0 05-06-2012 11:40 AM
loop calculation الملك الراقي المواضيع المحذوفه والمكرره 0 05-06-2012 07:13 AM
VS 2005 Problems Manipulating Excel from Console App الملك الراقي المواضيع المحذوفه والمكرره 0 05-06-2012 07:13 AM
loop calculation الملك الراقي المواضيع المحذوفه والمكرره 0 05-06-2012 07:12 AM
VS 2005 Problems Manipulating Excel from Console App الملك الراقي المواضيع المحذوفه والمكرره 0 05-06-2012 07:12 AM


الساعة الآن 08:48 AM


Powered by vBulletin™ Version 3.8.8
Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.
Search Engine Optimization by vBSEO ©2011, Crawlability, Inc.
جميع الحقوق محفوظة لشبكة طرب العراق