You are viewing our Forum Archives. To view or take place in current topics click here.
anyone want to help me write in visual basic
Posted:
anyone want to help me write in visual basicPosted:
Status: Offline
Joined: Apr 18, 201212Year Member
Posts: 279
Reputation Power: 10
Status: Offline
Joined: Apr 18, 201212Year Member
Posts: 279
Reputation Power: 10
The task is as follows and i would love some help, any super easy quick ways to make this code? Maybe right a super short version and ill ammend. I will literally do anything for some help, i tried writing code in java but the sub functions did not work well will with global variables.
A biology class are going on a field trip. They have been given the task of catalouging the number of common minibeasts found within one square metre of woodland. To do this they lay a quadrat over a area of ground, not the coordinates of each minibeast they find and take a close-up digital photo as evidence (last bit is irrelivent)
The class will create a program to store the name and grid position of 6 common minibeasts.
The software will
. Allow one of six minibeats to be selected from a menu
. Enter and store the name and grid coordinate of the selected minibeast
.display how often each minibeats was found
.display the minibeast found at a selected coordinate
so basically the user enters the number 1 = slug 2 = centipede 3 = ladybird 4 = snail 5 = woodlouse 6 = worm 7 = end/exit
also struggled to end the loop when 'loop until valid_input = 7'
i need help, i nearly cried the other night after spending so long on this. So i decided to turn to the forums, i have been a member for a long time and used resources but i lost email account to a hacker :/
thankyou soo much, it really is my future in this code, probs take a pro minutes to make aha
cheers
what i have so far
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim minibeast(10) As Integer
Dim coordinate As String
Dim index As Integer
Dim how_many As Integer
index = -1
Do
index += 1
minibeast(index) = InputBox("enter number of minibeast")
lst_display.Items.Add(minibeast(index))
coordinate = InputBox("enter the coordinate of minibeast")
lst_coordinate.Items.Add(coordinate)
how_many = InputBox("How many of this minibeast was found at " & coordinate)
lst_how_many.Items.Add(how_many)
Loop Until minibeast(index) = 7
txt_amount.Text = index
End Sub
End Class
A biology class are going on a field trip. They have been given the task of catalouging the number of common minibeasts found within one square metre of woodland. To do this they lay a quadrat over a area of ground, not the coordinates of each minibeast they find and take a close-up digital photo as evidence (last bit is irrelivent)
The class will create a program to store the name and grid position of 6 common minibeasts.
The software will
. Allow one of six minibeats to be selected from a menu
. Enter and store the name and grid coordinate of the selected minibeast
.display how often each minibeats was found
.display the minibeast found at a selected coordinate
so basically the user enters the number 1 = slug 2 = centipede 3 = ladybird 4 = snail 5 = woodlouse 6 = worm 7 = end/exit
also struggled to end the loop when 'loop until valid_input = 7'
i need help, i nearly cried the other night after spending so long on this. So i decided to turn to the forums, i have been a member for a long time and used resources but i lost email account to a hacker :/
thankyou soo much, it really is my future in this code, probs take a pro minutes to make aha
cheers
what i have so far
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim minibeast(10) As Integer
Dim coordinate As String
Dim index As Integer
Dim how_many As Integer
index = -1
Do
index += 1
minibeast(index) = InputBox("enter number of minibeast")
lst_display.Items.Add(minibeast(index))
coordinate = InputBox("enter the coordinate of minibeast")
lst_coordinate.Items.Add(coordinate)
how_many = InputBox("How many of this minibeast was found at " & coordinate)
lst_how_many.Items.Add(how_many)
Loop Until minibeast(index) = 7
txt_amount.Text = index
End Sub
End Class
#2. Posted:
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
Did you just call voids subs?
SLAP SLAP.
SLAP SLAP.
- 0useful
- 0not useful
#3. Posted:
Status: Offline
Joined: May 21, 201113Year Member
Posts: 59
Reputation Power: 3
Status: Offline
Joined: May 21, 201113Year Member
Posts: 59
Reputation Power: 3
Do you go to a school in Glasgow?
- 0useful
- 0not useful
#4. Posted:
Status: Offline
Joined: Apr 08, 201014Year Member
Posts: 1,724
Reputation Power: 6
Status: Offline
Joined: Apr 08, 201014Year Member
Posts: 1,724
Reputation Power: 6
I wasn't sure if this was for Windows Console or Windows form, so considering you're not quite sure how to do this, I assumed you were after a console app.
Things to note:
-Some of the wording may need changed if this is a school project...
-It doesn't use 2D arrays (although better suited for the x-y co-ordinates).
I thought that might look a little confusing to read, so I used 1D instead.
-I have left comments in so it looks believable (if you're handing this in).
- [ Register or Signin to view external links. ]
- [ Register or Signin to view external links. ]
Things to note:
-Some of the wording may need changed if this is a school project...
-It doesn't use 2D arrays (although better suited for the x-y co-ordinates).
I thought that might look a little confusing to read, so I used 1D instead.
-I have left comments in so it looks believable (if you're handing this in).
- [ Register or Signin to view external links. ]
- [ Register or Signin to view external links. ]
Module Module1
Dim MiniBeasts() As Beast
Dim NumberOfBeasts As Integer
Structure Beast
Dim x, y As Integer
Dim name As String
Dim frequency As Integer
End Structure
Sub Main()
'Header shows the project title:
'Mutha.****.Biology
DisplayHeader()
'I have used multiple menus which slide
'under the title of "Header"
DisplayMainMenu()
Console.ReadLine()
End Sub
Sub DisplayHeader()
'This is purely for aesthetics
Console.Clear()
Console.WriteLine("=======================")
Console.WriteLine("Mutha. ****. Biology.")
Console.WriteLine("=======================")
End Sub
Sub DisplayMainMenu()
'Uses cache more efficiently and stops errors by using char
Dim MenuChoice As Char
'Display menu until user chooses exit
Do Until MenuChoice = ("4")
DisplayHeader()
Console.WriteLine(" MAIN MENU")
Console.WriteLine("-----------------------")
Console.WriteLine("")
Console.WriteLine("1. INPUT BEAST AND CO-ORDINATES")
Console.WriteLine("2. DISPLAY CURRENT RECORD OF BEASTS")
Console.WriteLine("3. HALP :c")
Console.WriteLine("4. EXIT")
Console.WriteLine("")
MenuChoice = Console.ReadLine()
'Select case menu is far more efficient
'than using if statements.
Select Case MenuChoice
Case "1"
'Get user input:
InputBeasts()
Case "2"
'Output data to user:
DisplayBeasts()
Case "3"
'Output help:
DisplayHelp()
Case "4"
'End/// 'nuff said.
End
End Select
Loop
End Sub
Public Sub InputBeasts()
'I have already dim'd the variables used in this sub
'as global variables (in the declarations)
'Uses the structure of Beast to get the x,y and name.
'This will be the limit of the frequencyer
'Get input to know what array size we are working with
Console.Clear()
DisplayHeader()
Console.Write("How many different types of minibeasts are there? ")
NumberOfBeasts = Console.ReadLine()
Console.WriteLine("")
'Redimension the 1D array so we can use loops
ReDim MiniBeasts(NumberOfBeasts)
'This generic for loop means ease of use without reprogramming
For i = 1 To NumberOfBeasts
Console.Write("Please input the [" & i & "] beast's name: ")
MiniBeasts(i).name = Console.ReadLine()
Console.WriteLine("")
'How many of each beast
Console.Write("Please input how many of the " & MiniBeasts(i).name & "s were found: ")
MiniBeasts(i).frequency = Console.ReadLine()
Console.WriteLine("")
'Now we get the x co-ord and store it in the x bit of the structure
Console.Write("Please input the x co-ordinate of where the " & MiniBeasts(i).name & "s were found: ")
MiniBeasts(i).x = Console.ReadLine()
Console.WriteLine("")
'And finally get the y co-ord and store it in the y structure
Console.Write("Please input the y co-ordinate of where the " & MiniBeasts.Count & " " & MiniBeasts(i).name & "s were found: ")
MiniBeasts(i).y = Console.ReadLine()
Console.Clear()
Next
End Sub
Public Sub DisplayBeasts()
'Cleans the console and displays the header
Console.Clear()
DisplayHeader()
'Gives us the table columns
Console.Write("Name" & vbTab & "Freq." & vbTab & "X Co-ord" & vbTab & "Y Co-ord")
Console.WriteLine("")
For i = 1 To NumberOfBeasts
'Writes out onto one line the: name, x co-ord and y co-ord
Console.Write(MiniBeasts(i).name & vbTab & MiniBeasts(i).frequency & vbTab & MiniBeasts(i).x & vbTab & vbTab & MiniBeasts(i).y)
'Starts a new line:
Console.WriteLine("")
Next
Console.WriteLine("")
Console.WriteLine("Press any key to return to the main menu")
Console.ReadLine()
Console.Clear()
End Sub
Sub DisplayHelp()
'Nothing fancy here, I need to work on getting the header
'back up though once you exit the help menu
Console.Clear()
DisplayHeader()
Console.WriteLine("Press 1 to input how many minibeasts there are")
Console.WriteLine("Then enter what the frequency of that beast is!")
Console.WriteLine("Then enter what the x co-ordinate is!")
Console.WriteLine("Then enter what the y co-ordinate is!")
Console.WriteLine("")
Console.WriteLine("Once you're done inputting your data:")
Console.WriteLine("Press 1 to re-enter data" & vbTab & ("Press 2 to display your data"))
Console.WriteLine("")
Console.WriteLine("Press any key to return to the main menu")
Console.ReadLine()
Console.Clear()
End Sub
End Module
- 1useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.