Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 149,920 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,013 people online right now. Registration is fast and FREE... Join Now!




What is wrong with my codes

 
Reply to this topicStart new topic

What is wrong with my codes

lanel75149
15 Dec, 2007 - 03:06 PM
Post #1

New D.I.C Head
*

Joined: 15 Dec, 2007
Posts: 3


My Contributions
This was to be set up like an eCommerce application. User have to enter User ID #, quantity of an item, & price of item. The module, I think should take parts of the Char

CODE

Module Module1
    Public Function fnVerify(ByVal strUserID As String) As Boolean
        Dim strFirstChar As String
        Dim strSecondChar As String
        Dim strThirdChar As String
        Dim strFourthChar As String
        Dim strFifthChar As String
        Dim strSixthChar As String = ("P")

        strFirstChar = strUserID.Substring(0, 1)
        strSecondChar = strUserID.Substring(1, 1)
        strThirdChar = strUserID.Substring(2, 1)
        strFourthChar = strUserID.Substring(3, 1)
        strFifthChar = strUserID.Substring(4, 1)


        If strFirstChar = strFifthChar Then
            Return True
        Else
            Return False
        End If

        If strFourthChar = strSecondChar + strThirdChar Then
            Return strSixthChar

        End If
    End Function
End Module

-------------------------------------------------------------------------------------------------------------------------------
2ND FORM - VERIFY BUTTON
When I click a button - verify user id matches a particular pattern. If registered -msg verified and total for order will show in textbox. If not registered -msg display and textboxes will be set to zero (quantity, price, and total)

CODE

Public Class itemVerifierForm

    Private Sub verifyButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles verifyButton.Click

        Dim userId As String


        userId = userIdTextBox.Text

        If fnVerify(userId) = True Then

            MessageBox.Show("You made it")
            
           ' calTotal()

        Else
            MessageBox.Show("You didn't make it")

            'clearfields()
            quantityOfItemTextBox.Clear()
            priceOfItemTextBox.Clear()
            totalPriceTextBox.Clear()

        End If

    End Sub

Write Sub Procedures to calculate total and clear entry fields.
Name it clearfields()  (NOT SURE WHAT TO DO HERE)
  
' Calculate Total Value of the order.

    Dim totalPriceString As String

totalPriceTextBox.text = (quantityOfItem * priceOfItem)

End Class

User is offlineProfile CardPM
+Quote Post

Martyr2
RE: What Is Wrong With My Codes
15 Dec, 2007 - 09:51 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,655



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
You just need to write a sub procedure called "clearfields" which will clear the boxes. From what it says, it asks for more than one procedure so I would call another calculateTotal. Here is an example...

CODE


private sub clearfields()
     quantityOfItemTextBox.text = 0
     priceOfItemTextBox.text = 0
     totalPriceTextBox.text = 0
end sub


private sub calculateTotal()
     totalPriceTextBox.text = quantityOfItemTextBox * priceOfItemTextBox
end sub


Now of course these would be called depending on the verification of the userID. If it passes, you would call calculateTotal() and if it failed you would call clearfields(). These are simple examples here, so make sure you do the proper error checking of your textboxes to make sure they are numbers. But the idea is there and should show you the way.

Enjoy!

"At DIC we be item calculating code ninjas!" decap.gif
User is offlineProfile CardPM
+Quote Post

lanel75149
RE: What Is Wrong With My Codes
16 Dec, 2007 - 07:24 PM
Post #3

New D.I.C Head
*

Joined: 15 Dec, 2007
Posts: 3


My Contributions
Thanks for your help


QUOTE(lanel75149 @ 15 Dec, 2007 - 04:06 PM) *

This was to be set up like an eCommerce application. User have to enter User ID #, quantity of an item, & price of item. The module, I think should take parts of the Char

CODE

Module Module1
    Public Function fnVerify(ByVal strUserID As String) As Boolean
        Dim strFirstChar As String
        Dim strSecondChar As String
        Dim strThirdChar As String
        Dim strFourthChar As String
        Dim strFifthChar As String
        Dim strSixthChar As String = ("P")

        strFirstChar = strUserID.Substring(0, 1)
        strSecondChar = strUserID.Substring(1, 1)
        strThirdChar = strUserID.Substring(2, 1)
        strFourthChar = strUserID.Substring(3, 1)
        strFifthChar = strUserID.Substring(4, 1)


        If strFirstChar = strFifthChar Then
            Return True
        Else
            Return False
        End If

        If strFourthChar = strSecondChar + strThirdChar Then
            Return strSixthChar

        End If
    End Function
End Module

-------------------------------------------------------------------------------------------------------------------------------
2ND FORM - VERIFY BUTTON
When I click a button - verify user id matches a particular pattern. If registered -msg verified and total for order will show in textbox. If not registered -msg display and textboxes will be set to zero (quantity, price, and total)

CODE

Public Class itemVerifierForm

    Private Sub verifyButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles verifyButton.Click

        Dim userId As String


        userId = userIdTextBox.Text

        If fnVerify(userId) = True Then

            MessageBox.Show("You made it")
            
           ' calTotal()

        Else
            MessageBox.Show("You didn't make it")

            'clearfields()
            quantityOfItemTextBox.Clear()
            priceOfItemTextBox.Clear()
            totalPriceTextBox.Clear()

        End If

    End Sub

Write Sub Procedures to calculate total and clear entry fields.
Name it clearfields()  (NOT SURE WHAT TO DO HERE)
  
' Calculate Total Value of the order.

    Dim totalPriceString As String

totalPriceTextBox.text = (quantityOfItem * priceOfItem)

End Class



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 02:42PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month