Validating and Clearing Forms

Discussion in 'Questions (Windows Mobile)' started by ashmoloy, Oct 24, 2009.

  1. ashmoloy

    ashmoloy New Member

    Hello, im new to Basic4ppc and have two questions.

    1. Is there a way to clear all my form fields at one go?

    2. Can i check/validate if any of the form fields(text) is left empty at one go?

    the code snippet would help :)

    Thx,
    Bakshi
     
    Last edited: Oct 24, 2009
  2. Erel

    Erel Administrator Staff Member Licensed User

    Here:
    Code:
    Sub Globals
        
    Dim controls(0)
        
    End Sub

    Sub App_Start
        Form1.Show
        
    Msgbox(IsEmpty)
        ClearAllTextboxes
        
    Msgbox(IsEmpty)
    End Sub

    Sub ClearAllTextboxes
        
    controls() = GetControls("form1")
        
    For i = 0 To ArrayLen(controls()) - 1
            
    If ControlType(controls(i)) = "TextBox" Then 'note that the control type is case sensitive.
                Control(controls(i), Textbox).Text = ""
            
    End If
        
    Next
    End Sub

    Sub IsEmpty
        
    controls() = GetControls("form1")
        
    For i = 0 To ArrayLen(controls()) - 1
            
    If ControlType(controls(i)) = "TextBox" Then
                
    If Control(controls(i), Textbox).Text <> "" Then Return False
            
    End If
        
    Next
        
    Return True
    End Sub
     
  3. ashmoloy

    ashmoloy New Member

    thx a ton... :sign0060:
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice