test for input in ASP page


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: test for input in ASP page

  1. #1
    Stephen Russell Guest

    test for input in ASP page

    I have some simple code:
    sub tbMessage_Change (sender as Object, E as EventArgs)
    lblMessage.Text = "Hello " + tbMessage.Text
    end sub

    I want to evaluate the tbMessage.Text to see if there is any content or
    empty in the submit. How do I do that. In VFP

    iif(empty(tbMessage.Text),"","Hello ") would be the code. What is the VB
    equiilvant?

    TIA

    __Stephen



  2. #2
    Phil Weber Guest

    Re: test for input in ASP page

    > I want to evaluate the tbMessage.Text to see if there
    > is any content or empty in the submit. How do I do that?


    Stephen:

    Sub tbMessage_Change (sender as Object, E as EventArgs)
    Dim sText As String = tbMessage.Text
    If Len(sText) Then
    sText = "Hello " & sText
    End If
    lblMessage.Text = sText
    End Sub

    ---
    Phil Weber



  3. #3
    Stephen Russell Guest

    Re: test for input in ASP page

    Thanks.
    __Stephen

    "Phil Weber" <pweber@nospam.fawcette.com> wrote in message
    news:3c65a336@10.1.10.29...
    > > I want to evaluate the tbMessage.Text to see if there
    > > is any content or empty in the submit. How do I do that?

    >
    > Stephen:
    >
    > Sub tbMessage_Change (sender as Object, E as EventArgs)
    > Dim sText As String = tbMessage.Text
    > If Len(sText) Then
    > sText = "Hello " & sText
    > End If
    > lblMessage.Text = sText
    > End Sub
    >
    > ---
    > Phil Weber
    >
    >




  4. #4
    Garry Mc Guest

    Re: test for input in ASP page


    There is an alternative syntax in VB.NET too,

    VB6: len(sText)
    VB.NET: sText.length = 0

    Personally I prefer to be more explicit and would rather see either
    if len(sText)= 0 then or
    if sText.length = 0 then

    I'm not sure which of the two is faster, but the VB.NET syntax will be the
    same in C# too (well the sText.length bit anyway).

    Garry Mc

    "Phil Weber" <pweber@nospam.fawcette.com> wrote:
    > > I want to evaluate the tbMessage.Text to see if there
    > > is any content or empty in the submit. How do I do that?

    >
    >Stephen:
    >
    > Sub tbMessage_Change (sender as Object, E as EventArgs)
    > Dim sText As String = tbMessage.Text
    > If Len(sText) Then
    > sText = "Hello " & sText
    > End If
    > lblMessage.Text = sText
    > End Sub
    >
    >---
    >Phil Weber
    >
    >



  5. #5
    Stephen Russell Guest

    Re: test for input in ASP page

    I'd rather be current in my code. Is there a way to see if blanks are all
    that are in the string? Or do I have to create my own class for an empty()
    function that parses through the string?

    Thanks for the object reference.

    __Stephen

    "Garry Mc" <garrymc@spam.itswebservices.com> wrote in message
    news:3c669ec1$1@10.1.10.29...
    >
    > There is an alternative syntax in VB.NET too,
    >
    > VB6: len(sText)
    > VB.NET: sText.length = 0
    >
    > Personally I prefer to be more explicit and would rather see either
    > if len(sText)= 0 then or
    > if sText.length = 0 then
    >
    > I'm not sure which of the two is faster, but the VB.NET syntax will be the
    > same in C# too (well the sText.length bit anyway).
    >
    > Garry Mc
    >
    > "Phil Weber" <pweber@nospam.fawcette.com> wrote:
    > > > I want to evaluate the tbMessage.Text to see if there
    > > > is any content or empty in the submit. How do I do that?

    > >
    > >Stephen:
    > >
    > > Sub tbMessage_Change (sender as Object, E as EventArgs)
    > > Dim sText As String = tbMessage.Text
    > > If Len(sText) Then
    > > sText = "Hello " & sText
    > > End If
    > > lblMessage.Text = sText
    > > End Sub
    > >
    > >---
    > >Phil Weber
    > >
    > >

    >




  6. #6
    Phil Weber Guest

    Re: test for input in ASP page

    > Is there a way to see if blanks are all that are
    > in the string?


    Stephen:

    Sub tbMessage_Change (sender as Object, E as EventArgs)
    Dim sText As String = Trim(tbMessage.Text)
    If Len(sText) Then
    sText = "Hello " & sText
    End If
    lblMessage.Text = sText
    End Sub

    ---
    Phil Weber



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center