Author Topic: Visual Basic Programmers, I need help!  (Read 2250 times)

Visual Basic Programmers, I need help!
« on: January 30, 2012, 03:21:04 PM »
Hello all, i have no idea if this code works because it is using a file that i created using a program which doesn't work (because of a bad record length, i'll have to ask my teacher tomorrow) basically, it opens a random access file (the one that was meant to be created before) and then compares the inputted details from the user to it to make sure the password/username match. please have a look and please tell me if i've done anything wrong :)
Code: [Select]
        Option Explicit On
        Imports System.IO
        Module Module1
         
            Structure Users
                <VBFixedString(16)> Dim strUsername As String
                <VBFixedString(16)> Dim strPassword As String
                Dim charAccountType As Char
            End Structure
         
            Sub Main()
                'declares the variables
               Dim strEnterPassword, strEnterUsername, FileName As String
                Dim blnCheck, blnUserCheck As Boolean
                Dim intAttempts, NoOfRecords As Integer
                Dim arrUserdetails As Users
                Dim noOfRecords As Integer
                Dim pos As Integer
                pos = 0
                FileName = "Datastore.dat"
                FileOpen(1, FileName, OpenMode.Random, , , Len(arrAccount))
                noOfRecords = LOF(1) / len(arrAccount)
         
                'initialises the variables
               strEnterPassword = ""
                strEnterUsername = ""
                blnCheck = False
                intAttempts = 0
                blnUserCheck = False
                Do While Not EOF(1)
         
                    FileGet(1, arrAccount)
         
                Loop
         
         
                Console.WriteLine("Enter your username")
                strEnterUsername = Console.ReadLine()
                Do Until blnUserCheck = True Or pos = noOfRecords + 1
                    If strEnterUsername = arrAccount.strUsername(pos) Then
                        blnUserCheck = True
                    Else
                        pos = pos + 1
                    End If
                Loop
                If pos = noOfRecords + 1 Then
                    Console.WriteLine(strEnterUsername & " " & "is not a valid username")
                ElseIf blnUsercheck = True Then
         
                    'sets up a loop that will finish when the statement becomes true or if it has been attempted 3 times
                   Do Until blnCheck = True Or intAttempts = 3
                        'asks the user to input their details
                       intAttempts = intAttempts + 1
                        Console.WriteLine("You have" & " " & 4 - intAttempts & " " & "attempts remaining.")
                        Console.WriteLine("Enter your password")
                        strEnterUsername = Console.ReadLine()
                        'checks if the statement is true or false, and outputs a relevant message
                       If strEnterPassword = arrUserdetails.strPassword(pos) Then
                            blnCheck = True
                            Console.WriteLine("Access granted")
                            Console.Read()
                        Else
                            Console.WriteLine("Details incorrect, please try again.")
                            Console.Read()
         
                        End If
                    Loop
         
                    'tells the user the attempts have been exceeded
                   If intAttempts = 3 Then
                        Console.WriteLine("You have exceeded the amount of password attempts.")
                        Console.ReadLine()
                    Else
                        Console.WriteLine("Access granted.")
                        Console.ReadLine()
                    End If
                End If
            End Sub
         
        End Module
"I luv how we where talken about amber killen her self and then it went to a kid that jacked off 42 times and died"
-C45.CCA.UNION-03.334

C18.CCA.JURY-RCT.527
Dr. Grigory Stulenkov
Steven Jessup

Offline [RG-O] jamiecross5

  • Gold Member
  • *
  • Posts: 104
    • View Profile
    • Awards
Re: Visual Basic Programmers, I need help!
« Reply #1 on: January 30, 2012, 04:46:39 PM »
This looks like you used a VB code on somphing that dosn't use the VB code, If its a data base I dont undersand what you have put, Most of it is errors and its too much to help you with, Sorry.
This photo is cursed.












Offline Penguin

  • Jesus Christ Is Real
  • Gold Member
  • *
  • Posts: 786
  • Awards [OCRP Award] Millionaire [OCRP Award] Secret Phrase [OCRP Award] Social Player [OCRP Award] You Own The Mall
    • View Profile
    • Awards
Re: Visual Basic Programmers, I need help!
« Reply #2 on: January 30, 2012, 09:21:07 PM »
Get a cleaner writing style, make it easily readable and documented.

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal