Guest User

Untitled

a guest
Jun 18th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.21 KB | None | 0 0
  1. Option Explicit On
  2. Imports System.IO
  3.  
  4. Module Module1
  5. Structure Account
  6. Dim intYear As Integer
  7. <VBFixedString(20)> Dim strFirstName As String
  8. <VBFixedString(20)> Dim strSurname As String
  9. <VBFixedString(22)> Dim strUsername As String
  10. <VBFixedString(2)> Dim strAccountclass As String
  11. <VBFixedString(22)> Dim strPassword As String
  12. Dim charForm As Char
  13.  
  14. End Structure
  15.  
  16. Sub Main()
  17. Dim intYear As Integer
  18. Dim blnAccount, blnYear, blnForm, blnPwordCheck, blnUcheck, existinguser As Boolean
  19. Dim strAccountType, strUsername, strConfPassword, strPassword, strfirstname, strsurname As String
  20. Dim arrAccount As Account
  21. Dim charForm As Char
  22. Dim filename As String
  23. Dim noOfRecords As Integer
  24.  
  25. blnUcheck = False
  26. existinguser = False
  27. filename = "C:\Users\David\computing\Datastore.txt"
  28. FileOpen(1, filename, OpenMode.Random, , , Len(arrAccount))
  29. noOfRecords = LOF(1) / Len(arrAccount)
  30.  
  31.  
  32.  
  33. Console.WriteLine("Welcome to the Greenpark Account Creation")
  34. Console.WriteLine("What is your first name?")
  35. strfirstname = StrConv(Console.ReadLine, VbStrConv.ProperCase)
  36.  
  37. Console.WriteLine("What is your second name?")
  38. strsurname = StrConv(Console.ReadLine, VbStrConv.ProperCase)
  39. Do Until blnAccount = True
  40. Console.WriteLine("What account type is this? P for Pupil, S for Staff")
  41. strAccountType = UCase(Console.ReadLine)
  42. If strAccountType = "P" Then
  43. blnAccount = True
  44. ElseIf strAccountType = "S" Then
  45.  
  46. blnAccount = True
  47. Else
  48. Console.WriteLine("That is an invalid account type")
  49. Console.ReadLine()
  50. End If
  51. Loop
  52. arrAccount.strAccountclass = strAccountType
  53. If strAccountType = "P" Then
  54. Do Until blnYear = True
  55. Try
  56.  
  57. Console.WriteLine("What year group are you in?")
  58. intYear = Console.ReadLine()
  59. If intYear >= 7 And intYear <= 13 Then
  60. blnYear = True
  61. Else
  62. Console.WriteLine("That is an invalid year group")
  63. End If
  64.  
  65.  
  66. Catch ex As Exception
  67. Console.WriteLine("Only enter a number")
  68. End Try
  69. Loop
  70. Do Until blnForm = True
  71. Console.WriteLine("What form are you in?")
  72. charForm = UCase(Console.ReadLine)
  73. If charForm = "A" Then
  74. ElseIf charForm = "B" Then
  75. ElseIf charForm = "C" Then
  76. ElseIf charForm = "D" Then
  77. ElseIf charForm = "E" Then
  78. ElseIf charForm = "F" Then
  79. ElseIf charForm = "G" Then
  80. blnForm = True
  81. Else
  82. Console.WriteLine("That is an invalid form group")
  83.  
  84. End If
  85. Loop
  86. End If
  87.  
  88. Do While blnUcheck = False
  89. Console.WriteLine("Enter your desired username, must be no more than 11 characters")
  90. strUsername = Console.ReadLine()
  91. If Len(strUsername) > 11 Then
  92. Console.WriteLine("That username is not 11 characters.")
  93. Else : blnUcheck = True
  94. End If
  95. Loop
  96. Do While Not EOF(1) Or existinguser = True
  97. FileGet(1, arrAccount)
  98. If Trim(strUsername) = Trim(arrAccount.strUsername) Then
  99. Console.WriteLine("That username is already in use.")
  100. Console.ReadLine()
  101. existinguser = True
  102. Exit Sub
  103. End If
  104. Loop
  105.  
  106. arrAccount.strUsername = strUsername
  107. Do Until blnPwordCheck = True
  108. Do
  109. Console.WriteLine("Enter your password")
  110. strPassword = Console.ReadLine
  111. If Len(strPassword) > 11 Then
  112. Console.WriteLine("That password is too long.")
  113. End If
  114. Loop Until Len(strPassword) <= 11
  115. Console.WriteLine("Confirm your password")
  116. strConfPassword = Console.ReadLine
  117.  
  118. If Not strConfPassword = strPassword Then
  119. Console.WriteLine("Those passwords are different.")
  120. Else
  121. arrAccount.strPassword = Console.ReadLine
  122. blnPwordCheck = True
  123. End If
  124. Loop
  125.  
  126. arrAccount.intYear = intYear
  127. arrAccount.charForm = charForm
  128. arrAccount.strAccountclass = strAccountType
  129. arrAccount.strUsername = strUsername
  130. arrAccount.strPassword = strPassword
  131. arrAccount.strFirstName = strfirstname
  132. arrAccount.strSurname = strsurname
  133. FilePut(1, arrAccount, noOfRecords + 1)
  134. FileClose(1)
  135. Console.WriteLine("Account saved. Welcome to the GreenPark Reward Scheme System" & " " & Trim(strfirstname) & " " & Trim(strsurname) & " " & ", please log in with the details you just entered.")
  136. Console.ReadLine()
  137.  
  138.  
  139. End Sub
  140.  
  141. End Module
Add Comment
Please, Sign In to add comment