We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Loop with textbox

Thread ID:





1564 Nov 12,2002 08:43 AM UTC Nov 12,2002 11:37 AM UTC WinForms 1
Tags: FAQ
Asked On November 12, 2002 08:43 AM UTC

Hi, I want to write a loop where the loop is a textbox in a form For i = Textbox1 to Textbox20 do something next i Problem: it cannot be a String or a textbox of an form or an object of an form ? it only works if i is an integer So i did the follwoing: Dim i as integer, e string For i = 1 To 20 e = "Textbox" & r Msgbox e ' => brings up Textbox1 Textbox2 Textbox3..... ' how can i convert this string to be seen as a textbox (or the values in it) ' this I want to to next: If e <> "value as String" then do something next i So it does this: if "Textbox1" (as string) <> "value as String" what I want to do : if "current value of textbox1 (as string)" <> "value as string" So how can I loop through all textboxes ?

Replied On November 12, 2002 11:37 AM UTC

' I found the solution myself, for anybody who is interested here´s the code: ' The values of the textboxes are loaded into arrays Dim e As Variant, w As Variant e = Array(Me.Textbox1, Me.Textbox2, Me.Textbox3, Me.Textbox4, Me.Textbox5, Me.Textbox6) w = Array(Me.AnotherTextbox1, Me.AnotherTextbox2, Me.AnotherTextbox3, Me.AnotherTextbox4, Me.AnotherTextbox5, Me.AnotherTextbox6) ' Then the loop is done to check values in those boxes Dim r As Integer For r = 0 To 5 If e(r) <> "" And w(r) = "" Then do something End If Next r


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon