hello sir getting error when run the loop and going to last value of row count please help and i can not use the 2nd loop in the place of cells(?????) number how can i use this **Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index** *** What I have tried:*** Dim aa As Integer For Z1 = 0 To DataGridView1.RowCount If Me.DataGridView1.Rows(Z1).Cells(2).Value = True Then aa = 1 Else aa = 0 End If Me.DataGridView1.Rows(Z1).Cells(7).Value = aa If Me.DataGridView1.Rows(Z1).Cells(3).Value = True Then aa = aa & 1 Else aa …

Member Avatar
Member Avatar
+0 forum 1

Hi, from the result in my "for" loop, have stored four value. How to extract that value to show the value(sprintf) ? Kindly refer to the attached the image file. Thanks Regrads, nazif

Member Avatar
Member Avatar
+0 forum 2

Use Google's modern Go language (aka. golang) to convert a denary number (base 10) to a roman numeral. Just a good exercise to explore Go's map, slice, sort and for loop features. Note that in Go the **:=** is shorthand for assigning a type (by inference) and a value to a variable. A slice is like an array that can grow, and a map is a key indexed list. Go has only the for loop, but the syntax is very flexible and can accomplish all the usual loop duties.

Member Avatar
+2 forum 0

Hello! I have a little problem with a For Loop, this is a For Loop in my script: $last_id = $conn->lastInsertId(); for($a = $last_id ; $a > 0 ; $a--){ code.... } But it doesn't work because of `($a = $last_id ;`, the variable $a can't be set to the value of $last_id, but if set this for example `($a = 5 ;` it will work.

Member Avatar
Member Avatar
+0 forum 7

Hi Champs, Im using VBA for Excel. and Im trying to use the code below to move through records and increment their values by one since they meet a certain criteria Sub promotion() Dim x As Range Dim y As Integer Sheet2.Range("c2").Activate Do While y < 1002 y = ActiveCell.Row Set x = Sheet2.Cells(y, 3) x.Value = x.Value + 1 y = y + 1 ActiveSheet.Cells(y, 3).Activate Loop End Sub Except the records are too many and the process is abit slower, Can anyone show me a better way to implement this.

Member Avatar
Member Avatar
+0 forum 7

Hey everyone, I'm doing a practice problem and I'm stuck. The question is "Given an array a of n numbers (say doubles), consider the problem of computing the average of the first i numbers, for i ranging from 0 to n-1. That is, compute the array b of length n, where b[i] = a[0] + a[1] ....+ a[i]/(i + 1) for 0 <= i < n: Write a Java program to solve this problem. Your program can generate its own array, for example a[i] = i + 1. See how large an array you can process in less than 5 …

Member Avatar
Member Avatar
+0 forum 2

#include<stdio.h> #include<conio.h> struct Book { char bname[20]; int pages; char author[20]; float price; }b1[3]; void main() { struct Book b1[3]={ {"BOOK1",700,"ypk",12.98}, {"BOOK2",500,"aak",350.00}, {"BOOk3",120,"HST",450} }; for(int i=0;i>3;i++) printf("%d\n",b1[i]); getch(); } iwant output book1 700 ypk 12.98 book2 500 aak 350.00 book3 120 hst 450.

Member Avatar
Member Avatar
+0 forum 1

Hi all , I have a set-interval function inside a for loop and when inside the set-interval function if it meets a criteria give an alert and clear the interval. Below is my code but its not working can anyone tell what the mistake here. var timeCheck = 0; function matchTime() { for (var i=0;i<timers.length;i++) { timeCheck = setInterval(function () { var theDate = new Date(timers[i][0]*1000); var now = new Date(); if ( (now.getFullYear() === theDate.getFullYear()) && (now.getMonth() === theDate.getMonth()) ) { if ( (now.getDate() === theDate.getDate()) && (now.getHours() === theDate.getHours()) ) { if ( now.getMinutes() === theDate.getMinutes() && (now.getSeconds() …

Member Avatar
Member Avatar
+0 forum 1

i was on the site pyschools working through the exercises, but i dont understand why it wont accept the code i input. [url]http://www.pyschools.com/quiz/view_question/s4-q2[/url] Create a function generateNumbers(start, end, step) that takes in three numbers as arguments and returns a list of numbers ranging from start to the end number (inclusive)and skipping numbers based on the step specified in the arguments. Note: The function range(x, y, z) can takes in 3 arguments. For example, range(1, 11, 2) will return a list of numbers [1,3,5,7,9]. Examples [CODE] >>> generateNumber(2, 10, 2) [2, 4, 6, 8, 10] >>> generateNumber(10, 10, 1) [10] >>> …

Member Avatar
Member Avatar
+0 forum 7

i have to do a pyramid with a pattern like this [iCODE] 1 1 2 1 1 2 4 2 1 1 2 4 16 4 2 1[/iCODE] i just realized dani web didnt take my center pyrmaid thing it moved to the side no matter what spacing i did this is the pattern but the height is not 4 as it is now, it is 8 and width is 15 so far i have done something like this [CODE] public class pyramid { public static void main(String args[]){ int w = 8; for(int count =1; count<=w;count++){ for(int a = …

Member Avatar
Member Avatar
+0 forum 5

I have the task of writing a function to determine the outcome of a game of tictactoe, i at first thought use a couple of for loops but that proved pointless, and then the only way i could think of was to write an if...elif...else statement for each row, column and diagonal. which isnt very impressive, so can anyone show me, or hint at a way to do this? below is exactly what it says on the site. [CODE] In the pencil-and-paper game, Tic-tac-toe, 2 players take turns to mark 'X' and 'O' on a board of 3x3 squares. The …

Member Avatar
Member Avatar
+0 forum 1

Create a function generateNumbers(num) that takes in a positive number as argument and returns a list of number from 0 to that number inclusive. Note: The function range(5) will return a list of number [0, 1, 2, 3, 4]. Examples [CODE] >>> generateNumber(1) [0, 1] >>> generateNumber(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> generateNumber(0) [0] [/CODE] i dont know how to do this. i tried; [CODE] def num(num): for x in range(num): lis = [] lis.append(x) y = x + 1 lis.append(y) return lis [/CODE] but it return the following; [CODE] num(10) [0, 1] …

Member Avatar
Member Avatar
+0 forum 5

I am having hard time understanding what the problem is with my code here. Basically I have a map that contains Key objects as the key, and Block* as the value. The point of this for loop is to print out the values that the key contains on to the console in the form of a game board. However it is only printing one role, in a infinite loop. the variable r never gets incremented for some reason. if you guys could help that would be great. Thanks in advance! for (int r=0; r<rows; r++){ for (int c =0; c<columns; …

Member Avatar
Member Avatar
+0 forum 2

i have to write a program that displays the value of pi for values for i = 10000,20000.....,and 100000 i have to use the following series pi = 4(1-(1/3)+(1/5)-(1/7)+(1/9)-(1/11_+...+(1/(2i +1))-(1/(2i +1)) any ideas i have to do a program with looping i cant use arrays can someone give me a hint and a strategy on how to do this problem

Member Avatar
Member Avatar
+0 forum 40

Hi i am just new to VB.NET and our teacher told us to experiment on for loop in a ODD SUM Program you need to add all odd numbers from Input One to Input Two like that but i can't stop it from adding continuously for example i input the first number 1 and the second 10 if i click the button one time the output should be 25 but when i click again the button it becomes 50 its wrong i can't terminate the process help me [CODE] Dim oddOne As Integer Dim oddTwo As Integer oddTwo = Val(txtInputTwo.Text) …

Member Avatar
Member Avatar
+0 forum 1

Hey, I made this code with the bits and pieces of knowledge i have, but i don't know how to convert it into a while loop. it is currently in a for loop. the program counts how many certain letters there are in a sentence/ word. String word; String letter; int index=0; char singleLetter; Scanner keys = new Scanner (System.in); System.out.println("What is your word?"); word= keys.nextLine(); System.out.println("What is your letter?"); letter=keys.nextLine(); singleLetter = letter.charAt(0); for( int i = 0; i < word.length(); i++ ) { if( word.charAt(i) == singleLetter ) { index++; } } System.out.println( "The letter " + letter …

Member Avatar
Member Avatar
+0 forum 3

i have the following code for getting the number of files on a drive: [CODE] Dim num As Integer = 0 Dim drive As String = "C:" For Each File In System.IO.Directory.GetFiles(drive,"*",System.IO.SearchOption.AllDirectories) Try num += 1 Label5.Text = String.Format("Files found: {0}", num) If num > 50 Then RaiseEvent start() End If ProgressBar1.Maximum = num Catch ex As Exception Continue For //Continue Loop End Try Next [/CODE] I want to skip the files which i dont have access to. But my error is occuring before the try hence i am not able to continue the loop. Please advice on how should …

Member Avatar
Member Avatar
+0 forum 7

Hello, I was hoping that someone can help me with this. I have this linking list working, but I have one problem, when I click on the link it shows up with the link like this winner.php?service=1&&year=2010 and honorable.php?service=1&&year=2010&award=1 this is for all years not just 2010, and what I need it to do is show winner.php?service=AM&&year=2010 and honorable.php?service=AM&&year=2010&award=Notables I have looked in my db, and the values are correct, so I know that is not the issue. [CODE]<ul> <?php $row['year']='2010'; while($row['year']>'2000') { ?> <li> <?php if($row['service']='AM' && $row['award']='Winner') { ?> <a href="winner.php?service=<?php print $row['service'];?>&year=<?php echo $row['year'];?>"><?php echo $row['year'];?></a> <?php …

Member Avatar
Member Avatar
+0 forum 3

Okay here's what I'm trying to do use a for loop get 5 numbers from input ONE number at a time. Output the sum and average of the 5 numbers. I am only allowed to use a maximum of 2 variables to solve this problem. Heres my code so far, please help me to find error? it compiles but doesnt compute [CODE]#include <iostream> using namespace std; int main() { int startNum; int nextNum; cout<<"Please Input a number " <<endl; cin >> startNum; for(startNum=0; startNum + nextNum<=5; nextNum++) { cout<< startNum+nextNum+nextNum+nextNum+nextNum<< " is the sum of all numbers " <<endl; cout<<endl; …

Member Avatar
Member Avatar
+0 forum 5

Write a program that prompts the user for an odd positive integer, n, greater than 1, and then prints the following hourglass figure which has a height of n text lines: In this example: n = 9 ********* (please refer to the attachment for the figure) * * * * * * * * * * * * * ********* Your program should check that the user enters a valid number for n and print an error message if not. Make sure to use the right method. Your output should look exactly like the figure above: symmetric and left-justified, with …

Member Avatar
Member Avatar
-1 forum 9

I fear from loop statements that's why I cannot figure this thing out. I understand the concept put I do not have bigger picture. Here I would like to close the application after the person try 3 times putting the wrong password. [CODE]Public Class MainForm Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click Me.Close() End Sub Private Sub PasswordTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PasswordTextBox.Enter PasswordTextBox.SelectAll() End Sub Private Sub PasswordTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles PasswordTextBox.TextChanged messageLabel.Text = String.Empty End Sub Private Sub verifyButton_Click(ByVal sender As Object, ByVal e …

Member Avatar
Member Avatar
+0 forum 1

Hi everyone, I am doing a program here to ask question about alphabet, and i am only in the middle of it and i face some problem that i really cant solve, need some help here... ok the problem is, for(int j =0; j<20;j++), in output, the 1st jlabel.setText(j) is 0, 2nd straight away became 19, means it skipped from 1 to 18, really want to know whats wrong, here is my code btw if your are copying this codes into program and trying it, in the output, just ignore everything in the 1st page and press "Begin" button to …

Member Avatar
Member Avatar
+0 forum 4

The code below is the file for the constructor method and the get methods [code] //Date: 3/18/2010 public class Taxpayer { private int socSec; private double yearlyGross; public Taxpayer(int taxPayer, double income) { socSec = taxPayer; yearlyGross = income; } public int getSocSec() { return socSec; } public double getYearlyGross() { return yearlyGross; } } [/code] Next is the code for the for loop printing of the constructor and get method in another file [code] //Date: 3/18/2010 public class UseTaxpayer { public static void main(String[] args) { Taxpayer[] somePayer = new Taxpayer[10]; int x; for (x = 0; x < …

Member Avatar
Member Avatar
+0 forum 5

[code] //Date: 3/17/2010 import java.util.Random; public class Bingo { public static void main(String[] args) { Random bingo = new Random(); for (int i = 1; i <= 50; i++) { System.out.println("Card #" + i + "\n********"); System.out.println(); for (int j = 1; j <= 24; j++ ) { int bingoNum; bingoNum = bingo.nextInt(75); System.out.print(" " + bingoNum); } System.out.println(); System.out.println(); } } } [/code] Basically, I wanna place the 24 numbers on 5 rows, 5 columns, with the 3rd row/3rd column blank, just like a bingo card setup is. How do I tell it to do a new line every …

Member Avatar
Member Avatar
+0 forum 8

[code] //Date: 3/16/2010 import javax.swing.*; class PizzaChoice { public static void main(String[] args) throws Exception { char[] whatSize = { 'S', 'M', 'L', 'X'}; char size; double[] sizePrice = {6.99, 8.99, 12.50, 15.00}; int s; System.out.println("What size do you want?"); size = Character.toUpperCase((char)System.in.read()); for (s = 0; s < whatSize.length; ++s) { if (size == whatSize[s]) System.out.println("Your pizza price is $" + sizePrice[s]); } } } [/code] That top section is for the command prompt, below is what I conjured up for a dialog input box and message box, but it doesn't work to the finish!! [code] //Date: 3/16/2010 import …

Member Avatar
Member Avatar
+0 forum 9

hi im trying to create a C# program that'll display * ** *** **** *** ** * type pattern but i can only get mine to look like this when i try to add on to the code * ** *** **** and then it stops. can anyone help on how im supposed to add the second part of the code?? [CODE]// week 05 program 01 // creating a simple pattern of asterisks using System; using System.Text; namespace AsterisksPattern { class Asterisks { public static void Main(string[] args) { // start loop from 0 for (int x = 0; x …

Member Avatar
Member Avatar
+0 forum 5

I'm a noob when it comes to C programming. I wrote a simple program that runs an infinite for loop. But inside that loop I wanted to create another loop to stop the user three times after entering incorrect passwords. I tested from different angles it seems like the infinite loop ignore my other loop. What should I do to stop the user from entering endless bad password? for(;;) { if(password==USER_ID) { run program; break; // if true the program runs and stop loop, no problem } else if(password!=USER_ID) { for(count=0;count<3;count++) { display an error message; ask user to type …

Member Avatar
Member Avatar
+0 forum 8

The End.