How To Simplify Loops

Dec 5, 2011

I would like to simplify a do loop.

View 1 Replies


ADVERTISEMENT

Monthly Payment Calculation, For Loops To Do While Loops?

Oct 8, 2011

the purpose of the program is to display the monthly payments on the loan.My homework is to use do while loops instead of for loop.Here is the code for the for loop.

Option Explicit On
Option Strict On
Option Infer Off

[code].....

Now I'm having some trouble displaying the output using the do while loop, and I'm pretty sure it's a loop problem on my code. However, I cannot seemed to find out what's wrong. I looked at the examples of do while loop in my textbook, but I couldn't find anything useful to my problems of my program.This is the output for the do while loop.

Here's the do while loop code

Option Explicit On
Option Strict On
Option Infer Off

[code].....

View 3 Replies

Contain Functions(They All Have For Loops) Don't Work In For Loops?

Mar 6, 2011

When I use a For loop in a For loop the Contains Statement dosen't work! Even my custom one! I even tested mine and it works 100% And neither that or the String.Contains function work inside of For Loops And, I know both of them use loops to search through a string.

My function(It will atleast search once):

Function RealContains(ByVal load As String, ByVal needle As String) As Boolean
load = load.ToLower

[CODE].....................

View 10 Replies

How To Simplify The Code

Jun 8, 2012

I was just wondering how you would go about simplify this code as its getting very annoying manually going through and changing the index value for the arrays.

[code]...

View 1 Replies

Simplify My IF Statement?

Mar 10, 2010

So I have here a sub, that is called to check values in my program. It works as it is, but it is a very long line of code. I know there must be a way to simplify this. As long as it uses fewer than 10 lines (even though this is 3 lines, split up. Same thing in reference).

If (btnArry(1) = btnArry(2) And btnArry(2) = btnArry(3) And Not btnArry(1) = Nothing) Or _
(btnArry(4) = btnArry(5) And btnArry(5) = btnArry(6) And Not btnArry(4) = Nothing) Or _
(btnArry(7) = btnArry(8) And btnArry(8) = btnArry(9) And Not btnArry(7) = Nothing) Or _[code]....

View 12 Replies

Can Any One Simplify CrazyPennie CODE

Nov 7, 2009

In my Previous Thread < My First DATA Base Application > About DATABASE Crazypenie Give me Code:[code]

View 7 Replies

Simplify The Handles Clause In A Sub?

Nov 14, 2009

Is there a way to simply the Handles statement? What if i want this sub to handle 20 textboxes do I have to list each textbox there? I already have a loop in my script so i can cycle through my textboxes ("TextBox" & i.text). is there anyway to use a variable or a function after handles to get all the names of the text boxes?

Private Sub textChange(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress,TextBox2.KeyPress, TextBox3.KeyPress, TextBox4.KeyPress, TextBox5.KeyPress

View 8 Replies

Asp.net - Simplify Email Body In String?

Oct 20, 2009

I'm just wondering about this one. I'm creating an ASP.NET webform containing lots of textboxes etc. And I want to send an e-mail based on this stuff. And the e-mails body needs to go into a string. And the string is supposed to contain HTML code, but the syntax changes because of the string. So how can I simplify this? Is there any software or something that lets me do this? Perhaps paste in some HTML code and then convert this to string format, ready to use with vb.net?

View 2 Replies

Simplify And Optimize This Checksumming Code?

Jan 27, 2011

Public Function CalCheckSum(ByVal ByteList As List(Of Byte)) As List(Of Byte)
Dim total As Integer = 0
For Each b As Byte In ByteList

[code]....

View 1 Replies

Simplify A Weekly List Of Events For A Web Site

Aug 17, 2009

I am writing a program to help simplify a weekly list of events for a web site without having to manually edit HTML code every single week.

The program takes event information from the user, stores it in a list box, and generates HTML code based on the user entry. The program basically enters in the user's inputted fields into a pre-set HTML template.

Here's how it's done:

1) I have a number of text boxes that the user fills out: "Date" "Event Title" "Age" "Location" "Details" etc.

2) The user clicks on the "ADD" button to store this event. The "Event Title" is shown in the list box, but I'd like for all of the information that was taken from the user before they clicked on "ADD" to be recalled in another text box.

3) The user can move events up or down in the list box, or remove them completely.

4) When the events have been sorted, the user hits the "GENERATE CODE" button and the html code is generated.

So lets say the list looks like:
- DJ Jim at Katrina Lounge
- DJ Heather at Zanzibar
- DJ Manny at Skybar

When the user clicks on the "DJ Jim" event, the full details that they entered earlier will be shown in a text box to the right of the list box. When they click on the "DJ Heather" event, the text box will reflect the details they entered for the "DJ Heather" event, and so on.

When the user click on "Generate", the program must be able to go through each item in the list box, recall the event details for that item, and plug in the variables for that item into the HTML code template.

The main question is, how can I store the information for each event (Event Title, Date, Location, etct.) while displaying only the Event Title for that even in the list box? If I know how to code this, it will be simple to display this information in the text box and recall the variables to plug into the HTML code

So the structure would be:

CODE:

View 3 Replies

Refactoring - Possible To Simplify (refactor) My Program Code (VB 2010)?

Jun 27, 2012

I have created a simply Pizza program (for a summer project not education related) that uses check boxes to determine what the customer wants. Basically a simple pizza ordering program.I was wondering as I have used the If statement over and other again for different parameters and variables, is it possible to use multiply arrays to simply the VB Code...I was advised to use Constructors in VB.Net Or is there a more simpler way to go about creating this program...or a better way of programing?What about decreasing the repetition in the code?

[code]...

View 4 Replies

Simplify Code For 3 DataGridView Controls In Winform Application?

Jun 6, 2011

I have following code for 3 DataGridView Controls in my VB.NET winform application. How can I simplify this code?

With DataGridView1
.Columns.Add("Column 0", "TaskName")
.AutoResizeColumns()[code]........

View 3 Replies

Socket Programming And Telnet Class For .NET To Simplify The Sending And Receiving Of Data?

Sep 28, 2009

I'm writing a GUI-based app in VB.net that talks to a LambdaMOO server via telnet, sends commands to display the object hierarchy, then parses the output and creates a visual representation of the object hierarchy.So my question is: is there some kind of "telnet client" class for .NET to simplify the sending and receiving of data, or do I have to write my own using the socket API?

View 7 Replies

For Loops In VB?

Nov 24, 2011

I have a 5 by 5 matrix I want to populate and I would like to simplify this into for loops. As I understand, I would need 2 for loops to complete this task?

Dim x(4, 4) As Char
x(0, 0) = Mid(key, 1, 1)
x(0, 1) = Mid(key, 2, 1)
x(0, 2) = Mid(key, 3, 1)

[code]....

View 1 Replies

Use Loops In .NET?

Apr 23, 2012

EDIT:I have a ItemList : Dim ItemList As New List(Of String)I wanna append each element from itemlist to a new list for 10 times each, then to start over again.How can I make a loop for each element while there are still elements in the list (10 times each)?I tried this but it's not working.

Private crt As Integer = 0
Private limit As Integer = 0
Private Function getline() As String
Dim line As String = ""

[code]....

but I didn't know where to add the 10 times limit and also the current item number(crt)

View 1 Replies

Doing Loops In .net Using Regexs?

Mar 30, 2012

I'm writing a super small interpreter in vb.net because i need to execute a simple (invented) language so the app understand it and do what ever it needs to do.Everything went well until i reached the control structures and the loops.So my question its, in a code that its executed line by line using a simple for each how can i match the "WHILE ;" AND "ENDWHILE;" and execute the code within it?

The first thing that came to my mind its kind of flag the line of the reader and read the content from that line until find "ENDWHILE;" and the store that to execute late, so keep isolating the code in parts until I've all parts and then execute it.But i'm not so sure how to code it or if my reasoning its correct.PD: I'm using regexs.

View 1 Replies

For Each In Combobox - Loops Twice

Mar 22, 2011

I did For each Loop in my combobox, but I noticed that it loops twice. When it reaches the last item, it loops back to the first item. I code it typically: For each itm As Object in combobox.Items

[Code]....

View 5 Replies

For..Next Loops VB 2008?

Dec 7, 2009

have a problem where I have an application that allows someone to enter two integers. The app then displays all the odd numbers between both integers and all of the even numbers between both integers. There are two text boxes and two labels: even and odd. How would I code a For..Next loop for this type of app. The part where I get confused is what do I determine and how do I

View 18 Replies

Looping Through Loops In XML?

Mar 24, 2010

This is for .net frameworke 3.5 and visual studio 2008 in VB.Net.Two things we would like to do: 1) loop repeating node blocks 2) loop (through repeating node blocks) within repeating node block loop
First thing:

How do you loop through an xml that has repeating node block (<STRUS name="1000A") and extract the following node? For example you want to extract the IdentificationCode in the node that has <SVALU name="ZRT" and is from pos="9".So, the following example has the IdentificationCodes (TGJ23, PGA12, TPX12)

<?xml version="1.0" encoding="UTF-8"?>
<DocSplitterReport xmlns:xsi="http://www.w3.org/2001/X .......
<STRUS name="ROOT" lineStart="-1" lineEnd="-1">
<STRUS name="TAC" lineStart="1" lineEnd="194">
<SVALUs>

[Code]...

View 9 Replies

Merge Two For Loops Into One?

Jun 27, 2009

Is it possible to merge two For Loops into one? I need this because I am using two for loops (1 to 100,000) to work with the data in a collection. The problem with this code is that it takes more than two hours two finish:

[Code]...

View 1 Replies

More Efficient For Each Loops?

Jul 26, 2011

Is there a more efficient way of doing this code?

For Each row As DataRow In dt.Rows
Dim ts1 As String = row(0).ToString
For index As Integer = 1 To 9[code]....

View 2 Replies

Using Names In Loops?

Sep 30, 2011

Im somewhat new to VB, my first time writing a mildly long program... have a program that will create an unknown number of textboxes, then later I will need it to manipulate those textboxes. I set it up so it names them txt1, txt2, txt3 etc..How can I write a loop that will refer to each of these textboxes by name so I can do what I need with them, ie for example in

For i =1 to x
txti.text = i
next

this would make no sense...how do i write the names correctly so the computer can understate and loop them as txt1, txt2,...?

View 3 Replies

Calculating From Multiple Txt Using Loops?

Oct 17, 2011

Basically I have 4 empty textboxes. I need to calculate the total and averages of the numbers entered in them. So far, I've declared 4 variables and made it equal to the text that was input by the user. I'm stuck with the calculations tough. The user doesn't have to use all 4 boxes. So if he/she only entered 2 numbers, the total is divided by 2, not by 4 for the average. I think I'm supposed to use a for... next loop because the maximum iterations I should do is 4, but I'm not sure how to the code even if it is supposed to use a for loop. Otherwise, the rest of my project seems to work fine.

View 5 Replies

Cinema Tickets Using Loops?

Mar 19, 2012

im new to this site and also a beginner on visual basic During form load, the number items required in the Adult ticket and Child ticket CBO's must be populated with code using a single For Loop.The Items Collection in Design mode must not be used to populate these CBO's1. Movie ticket prices, taxes, and fees are as follows:a. Adult Matinee - $9.25

[Code]...

View 19 Replies

Euclid's Algorithm And While Loops

Mar 17, 2011

I have visual studio 2008, and we have been given specific tasks to carry our for our course, we have been asked to implement euclid's algorithm by using a while loop, doing so without the visual part of visual basic whatever that means an example of a question they gave was 1)HCF(88,26)=2 how I would go about doing this, as I am thoroughly confused, and deadlines are fast approaching.

View 3 Replies

Factorial Calculations Using Loops?

Jul 17, 2010

Trying to figure out how to calculate factorials via loops. Cant seem to figure out where to start when using loops.

View 9 Replies

For Each Loops With Resultset From LINQ 2 SQL?

Jun 15, 2010

The below code will fill User Records in "users".

Dim users= From p In oDbUser.USERs Where p.STATE= "MI" And p.STATUS = 1

how can i use a foreaach loop in the result and take each indidual row items ?

View 1 Replies

For Next Loops - Displaying Output?

May 9, 2011

I'm new in programming especially in vb.net and I have a problem displaying the following using for-next loops:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
...and so on...

Initially I wrote this code
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim row As Integer
Dim col As Integer
Dim txtNumber As Integer = CInt(TextBox1.Text)
[Code] ......

The output is this
1
2 3
3 4 5
4 5 6 7
5 6 7 8 9
... and so on...

View 2 Replies

For Next Loops Displaying Incorrect Value?

Feb 2, 2012

The Code has two options. Option one starts with 1 dollar and doubles everyday for 10 days. If this is correct the value should be $1024 but instead it shows double that ($2046)

The second option starts with $100 and adds $100 per day for 10 days. The number should come out to an even $1000 but instead shows $6500

Public Class Form1
Private Sub compareButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles compareButton.Click

[Code]....

View 1 Replies

How To Avoid Loops In Networks

Aug 14, 2010

I have a matrix for example (10 x 10) which represents 10 nodes. The matrix called MyMat(9,9) The rows of this matrix represent the source node (From Node) and the columns represents target node (To Node). It has 14 links which are randomly distributed. The non zero values represent the connections between nodes.

[Code]...

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved