Results 1 to 4 of 4

Thread: Convert Pseudo Code To Visual Basic

  1. #1
    hbz3xtreme is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0
    Join Date
    Dec 2016
    Posts
    1
    Reputation
    0

    Lightbulb Convert Pseudo Code To Visual Basic

    I'm new and have no idea how to do it, it needs to be combined.

    start
    perform housekeeping()
    while not eof
    perform mainLoop()
    endwhile
    perform finishUp()
    stop

    housekeeping()
    declare variables
    open files
    perform headings()
    read soccerRec
    return

    mainLoop()
    print soccerFirst, soccerLast, soccerTeam, teamName[soccerTeam]
    read soccerRec
    return

    headings()
    print heading1
    print heading2
    return

    finishUp()
    close files
    return
    start
    perform housekeeping()
    while not eof
    perform mainLoop()
    endwhile
    perform finishUp()
    stop

    housekeeping()
    declare variables
    open files
    perform headings()
    read soccerRec
    return

    mainLoop()
    count[soccorTeam] = count[soccorTeam] + 1
    read soccerRec
    return

    headings()
    print heading1
    print heading2
    return

    finishUp()
    soccorTeam = 1
    while soccerTeam <= 5
    print teamName[soccerTeam], count[soccerTeam]
    soccerTeam = soccerTeam + 1
    end while
    close files
    return

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    13,813
    Reputation
    1707
    Quote Originally Posted by hbz3xtreme View Post
    I'm new and have no idea how to do it, it needs to be combined.
    Then you should start learning VB.NET then. This is not a code-writing service but we can help you with specific issues. There's a link to a beginner tutorial in my signature and I would suggest that you work your way through that. If you have to convert pseudo-code to VB.NET code then I assume that this is for a class or course of some sort so I would think that you're already learning some VB.NET. If you have no idea at all then I'd suggest that you should go back and review what you've learned so far because you're not going to be assigned something that you haven't been given the tools to complete. Basically what I'm saying is that you need to try a bit harder to make a start at least because if you really can't do anything at all with the problem then I'd have to conclude that you should try something other than VB.NET programming.

  3. #3
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    13,813
    Reputation
    1707
    Let me provide an example. This is from your pseudo-code:
    Code:
    housekeeping()
    declare variables
    open files
    perform headings()
    read soccerRec
    return
    It says there "declare variables". Are you really telling me that you don't know how to declare variables? If you're not saying that then there's something you can do so why haven't you don it? It also says "open files". Do you know how to open a file in VB.NET? If so, why haven't you done it? If not, what effort have you made to find out? Basically, what you're doing is looking at the problem as a whole and assuming it's too hard. You need to break the problem down into parts. That's not hard because the pseudo code is broken down into sections and each section is broken down into lines. It's already done for you.

  4. #4
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    15,090
    Reputation
    2804
    declare variables
    That's not something you would put in pseudo code. Declaring variables should not be a separate step (and is not a description of code functionality), they are placeholders to keep some state during what code does, and should be declared when you need them, with closest scope needed. Example, need to keep result of a computation:
    Dim result = A + B

    Sometimes one needs a variable outside a code block for use inside the code block, then you would declare it with a default/empty value. Example, and this is no exception to the rule "declare when needed":
    Dim result = 0
    For c = 1 To 10
    result += c
    Next


    Declaring when needed also allows you to use type inference rather than explicitly declaring the type. Look at these examples:
    Dim result ' no type given, no value assigned, type is implicitly Object, which is wrong since need to keep Integer values
    Dim result = 0 ' type is implicitly Integer
    Dim result As Integer 'type is explicitly Integer, variable is unassigned, was this variable actually needed at this time?
    Dim result As Integer = 0 'type is explicitly Integer, value set, may have written more code than necessary

    Notice c variable in previous example? That is declared and type inferred with the For statement, no separate declaration needed.
    How to format posts with code blocks etc - present the problem/post properly

    Visual Studio Community 2017

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •