VS 2010 For/While Numbered Pyramid Loop?
Sep 30, 2010As topic, how can I print the following output using For Loop and While Loop
1
22
333
Below is the output I get when I use For Loop
[Code]...
As topic, how can I print the following output using For Loop and While Loop
1
22
333
Below is the output I get when I use For Loop
[Code]...
Right now the existing VB code I have uses GUID to generate "random" filenames on save.
For instance:
ff8514d389a041649fd8b925a32f2b51.jpg
e1c938560fc1464ab2138065fc4661d3.jpg
Instead I want a date stamp, Time Stamp, and numbered filename:
For instance:
20091015_131644_001.jpg <--(Date_Time_NumberIncrement)
20091015_131551_002.jpg
Or something along those lines. The current code (which saves a jpeg to a random GUID filename) is below:
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.IO
[Code] .....
Right now the existing VB code I have uses GUID to generate "random" filenames on save.
[code]...
Instead I want a date stamp and numbered filename:
[code]...
My program has 2d array to find number of blocks in a certain level and total blocks of a pyramid. I need to also find the number of odd and even blocks.
Do I redim with different logic? O could I use the same population and make the specific button calculate for me. What is the logic?
Here's what I have:
Public
Class
Form1
[Code]....
I have been tasked to build a simple application that has an input textfield, a button, and a large multiline textfield setup for displaying output> the user enters in the number of rows in the input textfield and presses the button> a pyramid made out of "O" should be created in the output textfield> for example: user enters 3 and presses the button> output in output textfield:
O
OO
OOO
OO
O
Here is the code I came up with so far:
Private Sub btndisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btndisplay.Click
Dim n As Long
Dim lngNum As Integer = CInt(txtinput.Text)
For n = 1 To lngNum
txtoutput.Text = "0" & vbCrLf
Next
End Sub
I have vb.net 2003. I have to output a pyramid of asterisks of six lines, 10 times (vertically). But the catch is that I have to use a loop. MsgBox("*" & vbCrLf & "* *" & vbCrLf & "* * *" & vbCrLf & "* * * *" & vbCrLf & "* * * * *" & vbCrLf & "* * * * * *") would give me one block of pyramid but how would I get a message box to display 10 of these at the same time? I'm pretty sure a nested loop would work but I've tried for hours and I can't get it to work.
It would look like this:
CODE:
I'm currently taking a VB class as a complimentary in college, so keep in mind that I'm lowest of the low when it comes to this. For my assignment, using a console application, I need to create a pyramid of stars, such as this:
Enter number of stars: 3
***
**
*
So far, I've gotten to the point where it'll display enter number of stars: 3
3
2
1
How do I convert the numbers into the symbol?
Makes the following statement about the code below:
**"The computer evaluates the loop condition in the Do...Loop statment to determine whether the loop instructions should be processed. In this case, the inputsales <> String.Empty condition compares the contenst of the input sales variable to the String.Empty value. As you know the String.Empty value represents a zero length, or empty, string if the inputsales variable is empty, the loop condition evaluates to True and the computer process the loop instructions. *If on the other hand the inputsales variable is not empty, the loop condition evaluates to false and the computer skips over the loop instructions.
Based on the code I think it is the opposite: ...that while the inputsales value is not empty it should evaluate to true and process the loop and if it is empty it should evaluate to false and skip the loop?
See below.
Option Explicit On
Option Strict On
Imports System.Globalization
[CODE]...
I can't get the loop to work. The calculator is suppose to show how far someone goes for each hour increment (i.e. if they punch in 3 hours, it should show a number for 1 hour, 2 hours and 3 hours; if they punch in 10 hours it should show a number for 1 hour, 2 hours, 3 hours....etc. up to ten hours, etc.) I can't get it to show anything except for the total number of hours traveled and total distance.
Private Sub DistanceButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DistanceButton.Click
Dim speedIsValid As Boolean
[Code]....
it is written in vb 2010 using for next loop to create a pattern like
1
12
123
1234 and so on
[Code]....
Looking on different sites, i'm getting difficulty in understanding nested for loop. About how it works?
View 8 RepliesI want to get data from a txt file.Then use line by line in loop.Means loop get a line then execute it then get next line and so on, up to a limit.Now what I have to do?? "For" loop is runs only for integers..
View 6 RepliesI'm using a picture box to show an animated gif on my form. When i created the gif, I set it so it only loops once. The gif plays correctly in a browser, but when i set the image of the picture box to my animated gif it continuously loops.
I only want to loop once through the images embedded in my animated gif when i set the image of the picture box. What is the easiest way to do this? Does anyone have or know of any sample code to do this? I have been searching this for a while, but have not been able to find anything.
I currently have a function that loads an XML and takes all of the nodes and makes an object with them and adds them to an array.I need to be able to now see if there are more than one xml doc in a folder, and if so also add their objects to the array until all of them have been read. How would I go about doing this? I've been searching through the System.IO. to see if I could find something but I haven't been able to yet.
[Code]...
I was wondering how someone could stop a For loop in the middle of it, according to parameters. I have tried but cannot find a solution that works, I suppose an example of this would be if a loop were increasing a label by 1 from 0 to 100 and the user sets it to end at 57 or any number in between and when the loop reached the number to stop.
View 8 RepliesHow can I loop TimeGetTime? Public Declare Function timeGetTime Lib "winmm.dll" () As Long Public Declare Function timeBeginPeriod Lib "winmm.dll" (ByVal uPeriod As Long) As Long
[Code]...
I'm trying to loop through a collection object in vb2010.The code was originally used in Vb6 The book said that I needed to code a NewEnumerator method first in order to be able to loop through my collection. I coded the following:
[code]...
It gives an error for IUnknown, staging that IUnknown is not accessible in this context because it is a 'Friend'.In the line in the function I removed the Set since it's no longer needed.The error message for this line is '_NewEnum' is not a member of 'Microsoft.VisualBasic.Collection'What are these messages and how do I fix this in VB 2010?m_colCourse is not a system collection.
I am looking for Visual Basic 2010 code that would loop through all the forms in a project, i.e., the equivalent of the following VB 6 code:dim frmFom as Form for each frmForm in Forms
View 4 RepliesI am looking for Visual Basic 2010 code that would loop through all the forms in a project, i.e., the equivalent of the following VB 6 code
View 1 RepliesI am using VB 2010 , I have a loop that takes something like 5 minutes until it's finish. I want to allow the user the option to stop it in the middle or whenever they want. There's a button which starts the loop, and after I click it the loop starts running and the button is sort of "stuck".I saw something called "background work" in the VB Toolbox, can it be a solution to my problem?
View 2 RepliesThe calculator is suppose to show how far someone goes for each hour increment (i.e. if they punch in 3 hours, it should show a number for 1 hour, 2 hours and 3 hours; if they punch in 10 hours it should show a number for 1 hour, 2 hours, 3 hours....etc. up to ten hours, etc.) I can't get it to show anything except for the total number of hours traveled and total distance.
rivate Sub DistanceButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DistanceButton.Click
Dim speedIsValid As Boolean
[code].....
What I'm trying to do is write a program to store my sports cards collection. Basically, just a forms based program that stores various data into files. Where I am stuck at the moment is I have a piece of code that opens a form to add card brands. It has a text box, and ADD button and a CANCEL button. What I want to do is be able to type a brand into the textbox and have it store it in a array when the ADD button is clicked, then allow another entry for another brand and have it stored into the array when the ADD button is clicked and so on until the CANCEL button is clicked. Then I would like for the data in the array to be written to a file. Where I'm having the problem is I can enter a brand name into the text box but the loop keeps adding that same brand name into the array.
Imports System.IO
Public Class AddCardBrand
Private CallingForm As Object
Private Sub btnAddBrandCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddBrandCancel.Click
Dim form As New StartScreen()
[Code] .....
I'm trying to load a file where this file has, like, 10 lines. And I want to load each line (0 to 9) to each TextBox in my app (TextBox1 until TextBox10). So, there's a way to do this with a counter?
Like this mine code (that doesn't works):
If (System.IO.File.Exists("configs.ini")) Then
Dim configs As String() = System.IO.File.ReadAllText("configs.ini").Split(vbNewLine)
Const Max As Integer = 9
Dim TextBoxes(Max) As TextBox
For i = 0 To Max
TextBoxes(i + 1).Text = configs(i)
Next
End If
I have a loop in my program that iterates at the start about 20,000 - 25,000 times per second. By the end of the loop, the iteration is down to about 6000 per second. [Code] The Alphabetize function merely returns the string with it's Chars in abc order. Can you see any bottlenecks or any reasons for the slowdown?
View 13 RepliesI'm doing an assignment for Uni and in my VB.NET form I have some checkboxes, I'm trying to loop through and clear them (I have a button which will clear the form). My problem is that there seems to be no property I can use to set the state of a checkbox when not explicitly telling VB which checkbox I want to use. for example, I can go
WineCheckBox.Checked = False
That will check the box, but I wand to DRY the code up a bit and not have to repeat this for each check box I have, this is what I was trying to do:
If TypeOf element Is CheckBox Then
element.Checked = False
End If
I've tried using element.CheckState and element.Checked and both times I get "Checked (or CheckState) is not a member of System.Windows.Forms.Control".
This is the whole block of code:
'clear the controls
For Each element As Control In Me.Controls
If TypeOf element Is TextBox Then
[Code] .....
I�ve had success using the GET method to retrieve a series of web pages but my new challenge requires me to use a POST > GET combo. I can get it to work once just fine but no more. I get the feeling that something isn�t closing or completing properly. When I try to do the second GetRequestStream() I can see from my sniffer app that nothing is being sent so when the next command to stream the POST data to the request session it fails. I removed it all from the loop and simplified it as much as possible. Can someone tell me why it fails?
Also as a general question is my tack or reusing WebRequests viable? Or is there a �best practice� for looping a POST > GET combo? I�ve been assuming that since nothing in the WebRequest changes besides the post data I�m sending, even its length remains the same, that I should be able to re-use it.
Dim Cookie As New CookieContainer
Dim encoding As New UTF8Encoding
Dim byteData As Byte()
[code]....
Note: The section after the �Experimental comment is a surrogate for the second iteration of the loop. The GET that normally follows the POST section has been removed.
(<td [^>]+>
ss|[^, ]<a href=""http://www.test.com/member.php?action=profile[^>]+>(<span [^>]+><strong>|<span [^>]+>|))[^<]+(<span [^>]+>|</strong></span></a>|</a>|</span></a>)
How do i turn that into a capture group so it only gets the text that is bold and removes the rest?Also how do i loop through all the result from that captured group text?
Basically what I have are two loops, one inside the other, that will run until the given condition is met. Exactly what I want. My problem is that I want to be able to use the controls, like buttons, while a loop is going on.
I originally did not think of this until I had built this part of my program, what I want to know is if there is a way to use controls while a loop is going on or if their is an alternative.
1)I know timers can be used to meet these goals, but they did not work out as I had hoped and using two timers (1 to represent each loop) I do not believe is efficient.
2)I have considered using recursion, but have found this may not be very efficient either and am not quite sure if this will do what I want.
These loops run as long as the number the user inputted. So it could theoretically run for 100,000+ times. I am not looking for speed, but it would be good if there were a faster method that allowed me to use controls while it loops.
I am calling a sub from a form load event. The procedure that is being called adds columns to a listview and then loops through an array to populate the listview. I have another procedure called after the loop that does not execute when the loop completes. Please advise as to what I am doing wrong for the code not to execute after the loop in the if/then/else statement or why it is not executing if I remove the if/then/else statement and just placed the called sub after the loop or why the code does not go back to the form load event and then call the next called sub.[code]
View 9 Repliesconverting this to parallel for loop, this will be my first time on parallel for loop. i have this nested for loop, it looks like this:
For i As Integer = 0 To FlowLayOutPanel.Controls.Count - 1
Dim TempUserControl As New UserControl
TempUserControl = FlowLayOutPanel.Controls.Item(i)
[code]....