11 Replies - 1137 Views - Last Post: 30 January 2012 - 09:02 AM Rate Topic: -----

Topic Sponsor:

#1 charyl  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 224
  • Joined: 29-June 11

Validate guest book in vb

Posted 29 January 2012 - 08:20 PM

If possible I need a tutorial or help. Just getting back into vb need a refresher. My assignment is to add validation when someone enters their name and email into a guest book. Validation controls should ensure user puts a name and valid email and a message. Class project, seems I've also signed up for an advanced class by mistake and will have to do my best until I can make other arrangements with teachers. Any help is appreciated. Went to msdn, didn't understand their verbiage and it looks more like php or another code other than vb. thanks.

This post has been edited by charyl: 29 January 2012 - 08:21 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Validate guest book in vb

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1759
  • View blog
  • Posts: 2,693
  • Joined: 08-June 10

Re: Validate guest book in vb

Posted 29 January 2012 - 08:34 PM

* Moved to the ASP.NET forum *

I'm assuming this is ASP.NET/VB.NET we are talking about here, because the other options don't make much sense in this context. Please correct me if I am wrong.
Was This Post Helpful? 1
  • +
  • -

#3 DimitriV  Icon User is offline

  • It's been so long, without this feeling
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,533
  • Joined: 24-July 11

Re: Validate guest book in vb

Posted 29 January 2012 - 08:40 PM

The title of the thread says "in vb" but you're in the ASP.Net forum!
Hey charyl. It's really nice to be meeting you on DIC again for the first time since November!
With msdn their code samples have a tab strip above them - one of the items is VB.

Next:
http://www.dreaminco...email-validity/
There was this thread with some good examples.

To check for a user name just call:
If username.Text = "" Then

username is a TextBox.
Anyway good to see you back and if you need anything I'm here but will be picking up my brother from school for the next half hour.
Was This Post Helpful? 1
  • +
  • -

#4 charyl  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 224
  • Joined: 29-June 11

Re: Validate guest book in vb

Posted 29 January 2012 - 09:23 PM

View PostAtli, on 29 January 2012 - 10:34 PM, said:

* Moved to the ASP.NET forum *

I'm assuming this is ASP.NET/VB.NET we are talking about here, because the other options don't make much sense in this context. Please correct me if I am wrong.


Yes, sorry. I am a little confused on this ASP.net! I really didn't mean to sign up for this class, but too late now. I'll look at Jimbo's link and come back to add my code if it doesn't help.
Was This Post Helpful? 0
  • +
  • -

#5 DimitriV  Icon User is offline

  • It's been so long, without this feeling
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,533
  • Joined: 24-July 11

Re: Validate guest book in vb

Posted 29 January 2012 - 09:25 PM

Sorry - are we talking about ASP.Net or VB.Net? The link I gave you was for VB.Net… 😒

Quote

I'll look at Jimbo's link and come back to add my code if it doesn't help.

I really hope it does…!

This post has been edited by jimmyBo: 29 January 2012 - 09:27 PM

Was This Post Helpful? 0
  • +
  • -

#6 charyl  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 224
  • Joined: 29-June 11

Re: Validate guest book in vb

Posted 29 January 2012 - 09:39 PM

View PostjimmyBo, on 29 January 2012 - 10:40 PM, said:

The title of the thread says "in vb" but you're in the ASP.Net forum!
Hey charyl. It's really nice to be meeting you on DIC again for the first time since November!
With msdn their code samples have a tab strip above them - one of the items is VB.

Next:
http://www.dreaminco...email-validity/
There was this thread with some good examples.

To check for a user name just call:
If username.Text = "" Then

username is a TextBox.
Anyway good to see you back and if you need anything I'm here but will be picking up my brother from school for the next half hour.


hey Jimbo! Good to know you're out there :). Need to get back into this, it's amazing how much one forgets in such a short time! Be back in a momment with more questions. Can't remember the if then statements for true and false.
Was This Post Helpful? 0
  • +
  • -

#7 DimitriV  Icon User is offline

  • It's been so long, without this feeling
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,533
  • Joined: 24-July 11

Re: Validate guest book in vb

Posted 29 January 2012 - 09:51 PM

If <variable> = False Then
Else
'the variables true
End If


Glad to see you're still studying programming. I'm about to go into year 8 at school so a big year ahead of me. It doesn't matter if you forgot, I'll do my best to coax you back into the stream. :) :D

This post has been edited by jimmyBo: 29 January 2012 - 10:11 PM

Was This Post Helpful? 1
  • +
  • -

#8 charyl  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 224
  • Joined: 29-June 11

Re: Validate guest book in vb

Posted 29 January 2012 - 10:18 PM

View PostjimmyBo, on 29 January 2012 - 11:51 PM, said:

If <variable> = False Then
Else
'the variables true
End If


Glad to see you're still studying programming. I'm about to go into year 8 at school so a big year ahead of me. It doesn't matter if you forgot, I'll do my best to coax you back into the stream.


I'm very proud of you Jimbo! You keep up the good work in school and maybe you'll change the world for the better!!! I'm finding that I enjoy programming more than designing. I went to observe a few people this past week to check out the work market in SEO companies and I can't wait for time to learn JQuery and learn how to use code from wordpress. Although this class is way over my head, it's in an area I really want to learn...coding websites, but I'm going next week to see if I can transfer to a less advanced class...minor fopa. I was in 137 and somehow signed up for 237...so If I can just get through this one project maybe they will let me transfer to the other class!

K, here's my code, most of it came out of different chapters. I think I'm suppose to put
If nameTextBox.Text = False Then
Else
'the variables true
End If



When I try putting this in the Protected Sub submitButton area it underlines everything below, right now the code works but I'm not sure where to put the above statement?

Partial Class Guestbook
    Inherits System.Web.UI.Page


   ' Submit Button adds a new guestbook entry to the database,
   ' clears the form and displays the updated list of guestbook entries
    Protected Sub submitButton_Click(ByVal sender As Object, _
       ByVal e As System.EventArgs) Handles submitButton.Click


        '-- a string.contains(value) returns true or false if anywhere in the string value is found... 
        'in this case the @ sign  

        ' create dictionary of parameters for inserting
        Dim insertParameters As New ListDictionary()

        ' add current date and the user's name, e-mail address and message
        ' to dictionary of insert parameters                              
        insertParameters.Add("Date", Date.Now.ToShortDateString())
        insertParameters.Add("Name", nameTextBox.Text)
        insertParameters.Add("Email", emailTextBox.Text)
        insertParameters.Add("Message", messageTextBox.Text)

        ' execute an INSERT LINQ statement to add a new entry to the      
        ' Messages table in the Guestbook data context that contains the  
        ' current date and the user's name, e-mail address and message    
        messagesLinqDataSource.Insert(insertParameters)

        ' clear the TextBoxes
        nameTextBox.Text = String.Empty
        emailTextBox.Text = String.Empty
        messageTextBox.Text = String.Empty

        ' update the GridView with the new database table contents
        messagesGridView.DataBind()
    End Sub ' submitButton_Click

    ' Clear Button clears the Web Form's TextBoxes
    Protected Sub clearButton_Click(ByVal sender As Object, _
       ByVal e As System.EventArgs) Handles clearButton.Click
        nameTextBox.Text = String.Empty
        emailTextBox.Text = String.Empty
        messageTextBox.Text = String.Empty
    End Sub ' clearButton_Click

End Class

Was This Post Helpful? 0
  • +
  • -

#9 charyl  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 224
  • Joined: 29-June 11

Re: Validate guest book in vb

Posted 29 January 2012 - 10:25 PM

Part of my confusion too is I'm using the pro version of vb, this was a little shocker, I have not done any coding in the pro version nor in the asp.net most of the coding up top was copy and paste from other projects.
Was This Post Helpful? 0
  • +
  • -

#10 DimitriV  Icon User is offline

  • It's been so long, without this feeling
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,533
  • Joined: 24-July 11

Re: Validate guest book in vb

Posted 29 January 2012 - 11:52 PM

Hey charyl,
Sorry it took me so long to get back - I've been thinking and I may just have a solution for you:
Partial Class Guestbook
    Inherits System.Web.UI.Page


   ' Submit Button adds a new guestbook entry to the database,
   ' clears the form and displays the updated list of guestbook entries
    Protected Sub submitButton_Click(ByVal sender As Object, _
       ByVal e As System.EventArgs) Handles submitButton.Click


        '-- a string.contains(value) returns true or false if anywhere in the string value is found... 
        'in this case the @ sign  
If EValudate(emailTextBox.Text) = False Then
MsgBox("Email address is wrong")
Exit Sub 'to prevent the rest of the code from executing anyway
Else 'it's fine:

        ' create dictionary of parameters for inserting
        Dim insertParameters As New ListDictionary()

        ' add current date and the user's name, e-mail address and message
        ' to dictionary of insert parameters                              
        insertParameters.Add("Date", Date.Now.ToShortDateString())
        insertParameters.Add("Name", nameTextBox.Text)
        insertParameters.Add("Email", emailTextBox.Text)
        insertParameters.Add("Message", messageTextBox.Text)

        ' execute an INSERT LINQ statement to add a new entry to the      
        ' Messages table in the Guestbook data context that contains the  
        ' current date and the user's name, e-mail address and message    
        messagesLinqDataSource.Insert(insertParameters)

        ' clear the TextBoxes
        nameTextBox.Text = String.Empty
        emailTextBox.Text = String.Empty
        messageTextBox.Text = String.Empty

        ' update the GridView with the new database table contents
        messagesGridView.DataBind()
End If
    End Sub ' submitButton_Click

    ' Clear Button clears the Web Form's TextBoxes
    Protected Sub clearButton_Click(ByVal sender As Object, _
       ByVal e As System.EventArgs) Handles clearButton.Click
        nameTextBox.Text = String.Empty
        emailTextBox.Text = String.Empty
        messageTextBox.Text = String.Empty
    End Sub ' clearButton_Click

Public Function EValudate(ByVal email As String) As Boolean
If email.Length > 3 And email.Contains("@") Then
Return True
Else
Return False
End Function

End Class


Try that - I can get back to a compiler tomorrow because I am at school but its untested as of yet.
I am going to report this post to a mod - if its VB then it should be in the VB forums.
Was This Post Helpful? 0
  • +
  • -

#11 charyl  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 224
  • Joined: 29-June 11

Re: Validate guest book in vb

Posted 30 January 2012 - 08:50 AM

I'll try the code. The project is late so it will not be accepted, but I don't care. I have to get back in the swing so I just want it to work.
Was This Post Helpful? 0
  • +
  • -

#12 charyl  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 224
  • Joined: 29-June 11

Re: Validate guest book in vb

Posted 30 January 2012 - 09:02 AM

k, I get a blue line under the word EValudate - tried EValidate - vb told me to change it to IValidator, but there's still a blue line. The other thing is the debug is grayed out. Not a choice? Is this because it's an asp? I viewed it in Browser and this is what popped up:

Server Error in '/Guestbook' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30002: Type 'System.Data.Linq.Mapping.DatabaseAttribute' is not defined.

Source Error:



Line 23:
Line 24:
Line 25: <Global.System.Data.Linq.Mapping.DatabaseAttribute(Name:="Guestbook")> _
Line 26: Partial Public Class GuestbookDataContext
Line 27: Inherits System.Data.Linq.DataContext


But there's a blue line under the IValidator. on line? I'll have to go back in the book and figure out how to add in the line numbers, they're not there, just installed this program a couple days ago.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1