Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8688425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:21:36+00:00 2026-06-12T23:21:36+00:00

I am attempting to print a diamond in Visual Basic. The top half of

  • 0

I am attempting to print a diamond in Visual Basic. The top half of my code works perfectly, but for some reason I can’t get the bottom half to work in a similar manner. In the bottom half, spaces are printed out after the o(used to make the diamond), and the decreasing number of o’s sends the program into an infinite loop? Can anyone help?

The bottom half may be completely wrong, I’m still working on it

Here is the code:

Option Explicit On
Imports System

Module diamond
    Sub Main()
        ' The o variable will make the "o" part of the diamond, the space variable will be for places without an "o". 
        Dim row, spaces, o as Integer  
        'Dim index as integer

        'For top half
        ' Count the row number.
        row = 1
        spaces = 9
        o = 1
        Do until row = 20
            ' Count of row increases every loop until half of diamond is done.
            row +=1
            ' Write 1 less space every line.
            For row = 1 to spaces
                console.write(" ")
            Next row
            spaces -=1
            'Write 2 more "o"'s every loop.
            For row = 1 to o 
                Console.write("o")
            Next row    
            o +=2
            Console.Writeline
        Loop
        'Top of the diamond is done

        'This is the bottom half, which will not work.
        row = 20

        Do until row = 40
            row +=1
            For row = 20 to spaces
                Console.write(" ")
            Next row
            spaces +=1
            'Write 2 less "o"'s every loop.
            For row = 20 to o 
                Console.write("o")
            Next row    
            o -=2
            Console.Writeline
        Loop
    End Sub
End Module 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:21:37+00:00Added an answer on June 12, 2026 at 11:21 pm

    The problem is that you’re using row as your row counter for the while loops and also as the loop index for the for loops. It’s accidental that the first half works at all. In the second half row never gets to 40 because it keeps getting hijacked by the for loops.

    Try For i = 20 to spaces, etc, instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to get my feet wet with python on Project Euler, but I'm
I am attempting to print a JSON that I get like this: jsonfields =
I am attempting to print some data from a class and it prints fine
I'm running the following code and I'm attempting to print the first element in
I am attempting to print something using a C# Winforms application. I can't seem
So I'm attempting to print a multiplication table in C# however I can't quite
I have the below code and I'm attempting to print out only the first
I am attempting to print a JPEG file that I reference using a Uri
I'm attempting to print a bitmap from an Espon receipt printer. The full error
When I print the result of the regex I am attempting to use to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.