monarchmk 24 Junior Poster in Training

Assuming that you already have Excel on target PC...
You can start with this declaration

Dim xl As New Excel.Application
Dim xlsheet As Excel.Worksheet
Dim xlwbook As Excel.Workbook

And you can add reference to "Microsoft Excel XX Object Library"

Also here is some short commands... as example from where to start... you can explore more of them, or if you use VBA commands are same..

Set xlwbook = xl.Workbooks.Open("c:\book1.xls") //This one opens workbook
    Set xlsheet = xlwbook.Sheets.Item(1) //This one selects sheet... xlwbook.Sheets.Add(...) adds new sheet ... etc...
    xlsheet.Cells(row,column).value = "A" //This one add value a to cells with assigned coordinates... almost same as Range...
monarchmk 24 Junior Poster in Training

In command1_click do a FOR loop until rs.EOF()

or

open recordset in command1_click event and in SQL syntax check for password and username but beware of SQL Injection

monarchmk 24 Junior Poster in Training

G-mail needs authentication,

import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;

private class GMailAuthenticator extends javax.mail.Authenticator {
            public PasswordAuthentication getPasswordAuthentication() {
                String user = "username@gmail.com";
                String pwd = "password";
                return new PasswordAuthentication(user, pwd);
            }

And you need to change session to

Session mailSession = Session.getInstance(props, new GMailAuthenticator());

and add this

props.put("mail.smtp.auth", "true");
monarchmk 24 Junior Poster in Training

Hi,

you did not read while post... I wrote

...You using switch..and while... when user enter that he like to VOTE you code goes to switch and enters case 2:... now in case 2 you ask for what team user likes to vote...
Here.. when user enters let say 2 for Barcelona.. you need to display
...

but i never tell you to delete this part of code :)
When you removed menu for voting, you remove input variable declaration and that's why you have number exception...

put this code back

String input = JOptionPane.showInputDialog(" Who will win the Champions League in 2010/11? "
                                                                  + "\n 1. Real Madrid"
                                                                  + "\n 2. Barcelona"
                                                                  + "\n 3. Chelsea"
                                                                  + "\n 4. Manchester United");

between line 49 and 50
and you are done program works...
For ++score you are ok, it is increment value of score than display new value, score++ is display score than increment value
But for case 3 no...
Now please remove case 3 (line 58-60) it will never execute because you intercept user answer for quit (3) in line 34 and quit program before it enters switch loop.

Like an extra for this code you can replace message in case 1: (lines 42-45) with this code

String messg="";
                   for (int a=1;a<game.length;a++)
                	   messg +=" Current Score for " + game[a] + " is: " + score[a] + " \n";
            	   JOptionPane.showMessageDialog(null,messg);

If you later add new team(s) you …

inni2626 commented: Excellent step by step guidance +1
monarchmk 24 Junior Poster in Training

I can see in my crystal ball that error is in line 7 in 2nd sub right after you declare variables...

:D.. come on, put some code here so we can see where is problem

monarchmk 24 Junior Poster in Training

Ok... you are almost done :)
You are missing this code.. I rearanged a little and add new array...

String game [] = new String [5];                
               int score[] = new int [5];
               game [1] = "Real Madrid ";
               score [1] = 250;
               
	       game [2] = "Barcelona ";
	       score [2] = 320;
               
               game [3] = "Chelsea ";
               score [3] = 140;
               
	       game [4]= "Manchester United ";
	       score [4]= 300;

This should be in your code... before while...
I aligned array numbers with vote question in line 36-40 (You asked 1 for Real 2 for Barcelona so i changed array game to be same as your question game[1]=Real, [2]=Barcelona...). Learn that code is yours... It is, maybe, "rule" that array starts from 0 but if you need array to start from other number... use it from that number, do not use arrays before it,that is not a mistake.

And also delete lines 53-65.. IF is not needed here. When you exit switch you are returned to while... code out of switch here is meaningless because in SWITCH we determine user actions and act upon them. Out of switch (in this code) we do not need anything, there is question what user like to do and that is all we need out of switch.

You using switch..and while... when user enter that he like to VOTE you code goes to switch and enters case 2:... now in case 2 you ask for what team user likes to vote...

monarchmk 24 Junior Poster in Training

you almost done it...

your function replaceAll should return String... as i can see you send string to function and than in function you replace all chars and than?... nothing...
So if you decide to use function for returning result than remake function like

public static String replaceAll(String text)

now add RETURN in end of function since you'll need to return value to parent class.

and than in line 14 where you call your function should be some changes.
in this line you call replaceAll whick now returns new formed string... So some string (or already defined textString) should receive new formed text.
In example...

...
{...
...
 String result=MyFunction(text);
  System.out.println(result);
...
...
}

 public static String MyFunction(String inputText)
{
   ...
   inputText=InputText + "A";
   return inputText;
}

and you should print result... In your code in line 16 you print blank line...
see example in my line 5.

monarchmk 24 Junior Poster in Training

hmmm...

Did not read whole post...

move this code

choice=Integer.parseInt(JOptionPane.showInputDialog("1. Display the current score for each possible response \n"
                                                               +"2. Vote \n " 
             	                                               +"3. Quit the program "));

below game[][] array definition... Array should e defined before anything..

how i'll give you an example what i think to do

i'll use WHILE condition... and SWITCH... just to make sample how this command can be used and implement in your code
I commented whole code.. copy code and try to execute it , and after that try to implement WHILE and SWITCH to your code (SWITCH will replace those IF... chains)

import java.io.*;
import javax.swing.*;  
public class monarch {

	public static void main(String[] args) throws Exception
	{
		while (true) // real syntax is WHILE (condition)... i'll put true for infinite loop// I'll control it via break; command later in code
			// with break; you tell Java to exit from loops (applies to FOR also)
		{
			int question=Integer.parseInt(JOptionPane.showInputDialog("Please enter your choice: \n " +
					"1. something...\n " +
					"2. somthing else.... \n " +
					"3. something else too... \n " +
					"4. QUIT"));
// Here i declare question as integer so later i would not have to convert string value to integers for comapartion.
			//First we will check if user need program termination...
			if (question==4) 
				{
				JOptionPane.showMessageDialog(null,"You choose to quit... bye..."); //Inform user that we quit and...
				break; //end of program... with break you terminate while true condition and exit the loop
				}
			
			//If not …
monarchmk 24 Junior Poster in Training

I'll try to make you a plan how code in this class should be positioned...

1. Variable definition. All variables should be here (more or less, not strict rule)
2. Fill arrays with start values. (array should be prepared for later use. For start maybe it will be easier if you use 1 array for names and 1 for scores.. like String game[] for names and int score[] for votes and fill it parallel.)
3. Define User Action (Ask user what to do and do some action according to user choice)
. 3a. Display score
. 3b. Vote
. 3c. Quit

IF 3a is selected do...
. print all arrays with current values... FOR cycle...
IF 3b is selected do...
. Display all names to user ( array[X][0]) ... FOR cycle
. Ask user for vote ...showinputdialog
. Increment vote for team
. Return to menu "user actions" (3)
IF 3c quit code

Here is your code in clean version. I won't write code for you, but I'll be here to help you all the way with your code
First try to reposition your code by above plan... or you can redefine plan if you like, but reposition you code by final plan.
It does not matter if its not working from start... we'll have to add some more function to code to work...

import javax.swing.*;
import java.io.*;

public class ChampionLeague { …
monarchmk 24 Junior Poster in Training

Hi, inni2662

I remove you comments from your first post and added mine. I do not understand.. your 1st post and your 2nd post are not same code... i start to change 1st post...
However there is something that i could not understand... there is point in your code where you start doing different tasks... like starting part when you ask user for action, and then suddenly you declare game array with length of USER DEFINED ACTION??? (User choose to quit and you declare array for voting??) and than you fill strings with names from array that depends on chosen user action. I corrected parts of your code just to have some starting point.
Now your code can be started, but it still contains huge errors. Also arrays could not be filled with this kind of code, as if user choose 1 than array game will be declared as game[1][2] and will fail in line with Chelsea with ArrayOutOfBoundsException because in code game is defined for only 2x2 fields.

Now from you i need info what this code should do... like this code seams little chaotic...

import javax.swing.*;
import java.io.*;

public class ChampionLeague {
    public  static void main(String[] args) //Java main class starts always with this procedure. This line is starting point of Java class.
{ 
        int choice;
        int Quit = 0; //It's better from start to adopt Java rules for variable names, or if you really need adopt your own rules but keep …
monarchmk 24 Junior Poster in Training

Thats because with every click you open new excel application. Please read my previous post, all of your problems are solved there.

monarchmk 24 Junior Poster in Training

You did not read my post at all????

I sad move lines 6-9 in new procedure FORM_LOAD like this

Private Sub Form_Load()
Set mailmwo = New Excel.Application
    mailmwo.Visible = True
    mailmwo.Workbooks.Open "C:\VB6\test.xls", , , , "", ""
    mailmwo.Worksheets("Sheet2").Select

End Sub

Also close codes should be in FORM_TERMINATE like this

Private Sub Form_Terminate()
    mailmwo.Workbooks.Close
    Set mwoBook = Nothing
    Set mailmwo = Nothing
End Sub

Above ALL STATEMENTS you should put this

Public mailmwo As Excel.Application
Public mwoBook As Excel.Workbook
...
...
...

And in Command1_Click procedure delete following lines 2,3,6,7,8,9,24,26,27 because
2,3 were moved in-front of all code
6,7,8,9 were moved in FORM_LOAD
24,26,27 were moved in FORM_TERMINATED

Now if you follow this everything will work.

monarchmk 24 Junior Poster in Training

Ok, now we have concept error... with this code on every click you open new Excel file...

in form_load event or another command button event which will be tagged "Open Excel" put code for excel opening (lines 6-9)
Lines 2-3 put it in front of first line and change Dim to Public
Lines 4, 12-22 are ok...

Now when you activate form (or click open button), it will open Excel file (first change lines 6-9)
With every click on CommandButton1 code will go through open excel file and search for text stated in txtscan box.

Also at the end do not forget to close worksheet, either with form or with another button.

monarchmk 24 Junior Poster in Training

About default values...
Only changeRate is enclosed in IF chain. By Java logic, IF condition may neever be satisfied so that variable may be left without value. So to be code safe Java ask for default value.Same is for WHILE, DO, SWITCH... All other variables are left out of any conditions and/or are part of some calculations or input for user, so that is why you need default only on changeRate.

On missed question... line 32 should be str = input.next(); not nextLine...

monarchmk 24 Junior Poster in Training

Line 13
should be double chargeRate=0;
Error is The local variable chargeRate may not be initialized.
Java loves if you assign default values to variables before you try to use them

And DO NOT move amountDue= (kwhUsed*chargeRate); Its position is correct. Line 60 there it should be. Only kwhUsed in above code is wrong positioned

Here is explanation why i tell you to move

in IF loop you count "chargeRate" with "kwhUsed" in calculation. So it is logical that kwhUsed should have some value (should be calculated) before you enter IF chain.
With "amoundDate". This line should stay below IF loop because it depends from "chargeRate" value that is calculated in IF chain.

monarchmk 24 Junior Poster in Training

simplest? maybe picture control with some code behind

monarchmk 24 Junior Poster in Training

from first look...
kwhUsed is defined AFTER it was checked??
line 57 should be in-front of IF where you define change rate (line 43)

monarchmk 24 Junior Poster in Training

Var. 1. If you put this
System.out.println(s);
after line sum+=s
result will be like
5
10
15
30

Var. 2. If you put this
System.out.println(i);
after s=i; line
result will be like this
1
2
3
5
6
10
15
30

In first case SOP is inside loop that check if divider is suitable for sum, so it will print only proper dividers which define perfect number. In second case SOP is in loop that only check if number is proper divider so this will print all proper dividers.

Please mark post SOLVE if this solves your task. If you have more questions i'll be glad to help

monarchmk 24 Junior Poster in Training

i'll try to explain first in theory than trough your code
I'll not change code for you but i'll guide and explain what should be changed. Also please use indent. You see difference between your code in your post and your code in my post. Here you can clearly see where some loop starts and where is its end. Like this code is easy readable.
For semi perfect number you need to find all proper dividers of number and then to check if sum of all or some of them will get you a value of number.
To find all proper divider you should use % calculation.
Then to find if that number is usable you should go from highest divider till 1 and check if sums are not bigger than number. This means that for every divider you should check if number is greater than sum of previous dividers and this one. If it is true than you can add this divider to sum.
With numbers through example ...
30 (15,10,6,5,3,2,1)
Step x. 29, 28,27...16 are not proper dividers...
Step 1. sum=0 check if 30-15 >= 0 OK sum=0+15
Step x. 14,13,12,11 are not proper dividers...
Step 2. sum=15 check if 30-(sum+10)>=0 OK sum=sum+10=25
Step x. 9,8,7 are not proper dividers...
Step 3. sum=25 check if 30-(sum+6) >= 0 NOT OK sum=25
Step 4. sum=25 check if 30-(sum+5) >=0 OK sum=sum+5 and we will issue break …

monarchmk 24 Junior Poster in Training

There is no LostFocus event on cell. There is Worksheet_SelectionChange but you could not use it as when you try to edit cell, Excel enters Edit mode and no macros can run while edit mode is in effect.

monarchmk 24 Junior Poster in Training

I have to disagree with monarchmk on the advisability of counting by twos. That's the very definition of counting by odds or evens. Counting by ones and then checking doesn't save you any code at all, and it adds an unnecessary decision in each iteration of the loop. This is horribly wasteful. Any time you can eliminate an if, do it. Never add them if you don't need them.

Also increasing by two gives you only odds or evens number which is not all number in sequence.If i misunderstood concept and you really need to check only odds or evens, put a for loop with i+=2 instead of i++ and you will get step by 2 counting.

i think my quote agrees with your quote. As is in my explanation i advice him to use num++ just to go through every number or if i misunderstood concept he can go with +2...
At the end of code @kay19 displays result of both evens/odds so by that i suppose if displaying of result is not conditional than calculating should not be conditional and should used every number. Problem is with task definition, thats why my answers was dependable from conditions.
And in this case using all numbers in if could reduce code cause he can put here content of two loops, from end of code, that are not needed for separate calculation.

i would release a code but than you will rep me -- :)

monarchmk 24 Junior Poster in Training

You stated all number between num1 and num2... why do you increment num1+=2? Its easier to go through all values between num1 and num2 and check which one are odds/even and make calculation depends of number type. It will reduce your code by half. Also increasing by two gives you only odds or evens number which is not all number in sequence. If i misunderstood concept and you really need to check only odds or evens, put a for loop with i+=2 instead of i++ and you will get step by 2 counting.
Also...
Line 30 and 37 should be num1++; (by my previous remark) (if you using your own code, or some other variable that start with num1 value if you are willing to listen @JamesCherrill opinion)
Line 34 should be only "else" because number %2 is either 0 or non 0 there is no alternative.
Also i assume that "evens" and "odds" are counter for even and odd. But in the way you are using it, it seams that you try to keep even/odd values, but you could not do it without array or simple add operation like evens+=num1. Or counting like evens++; depends of need.
Also for loop (line 56-66) is not needed. First in while loop you are checking for odds/even, then in 2 for loop you are checking for odds/even?.
When you check if value is odd or even, calculate sum directly.

Ok now line 44 you stated …

monarchmk 24 Junior Poster in Training

Here is another idea... instead of using timer for tracking time, why not use system. time on start and when something occurred (like class is not working) to recalculate time difference between start and current time? Even if you like to check time difference continually you can add timer and on timer event check time difference for whatever task you like.You will need at most 1 timer and 3-4 variables.

monarchmk 24 Junior Poster in Training

DFS... i things this is too simple problem for DFS... or maybe just my idea of implementation is complicated :), especially when there is only one combination(sum of only one line of numbers) that is correct.

monarchmk 24 Junior Poster in Training

I could write it but @jon.kiparsky would kill me...:twisted:

just kidding...

Please, start codeing... put some effort and we are all here to help if you had problems.

monarchmk 24 Junior Poster in Training

Sorry for second message, but time limit for editing expired..

And if you are looking for perfekt number then you should reduce your code only to sum of all proper dividers (as Taywin pointed) and if sum ==j then is prefect number

monarchmk 24 Junior Poster in Training

That doesn't sound right. It has to be 'all', not 'some'. The definition is on wikipedia. Also, it would not make sense to use only 'some' to be 'perfect'...

Hmm... My approach would do with searching for pair numbers of the number's factor which is not greater than its own square root value. :) Then simply add all of them up to see if it is the same as the given number.

Let say 30 is the number you are looking for.
The factor numbers of 30 which are less than or equal to its own square root (around 5.47...) are 2, 3, and 5.
The pair number for factor number would be [2, 15], [3, 10], [5, 6].
You always add 1 to the addition.
So compute 1+2+15+3+10+5+6 -> 42
and 42!=30, so it is not.

Please read header, your link is for PERFECT NUMBER, PSEUDO perfect number also known as SEMI PERFECT number, defined in wikipedia here http://en.wikipedia.org/wiki/Pseudoperfect_number like this:
In number theory, a semiperfect number or pseudoperfect number is a natural number n that is equal to the sum of all or some of its proper divisors. A semiperfect number that is equal to the sum of all its proper divisors is a perfect number.

So 30 is pseudoperfect number, not perfect number

@desert564
Not if(j-s!=0) you need Number - (sum of all proper dividers) >=0. See my explanation it should be

if(j%i==0) …
monarchmk 24 Junior Poster in Training

30=1+2+3+5+6+10+15 and is semiperfect /pseudoperfect number
but insted to searching differece between sum of proper dividers(42) and number(30), try to lower number to 0 starting with biggest number
30-15=15 > 0 OK (use it)
15-10=5 > 0 OK (use it)
5-6=-1 < 0 Not OK Skip
5-5=0 =0 OK (use it) break; (sum of used proper dividers=30=15+10+5)

20=1+2+4+5+10
20-10=10 OK
10-5=5 OK
5-4=1 OK
1-2=-1 <0 NOK Skip
1-1=0 OK break, pseudoperfect number but not because difference between (1+2+4+5+10=)22 and 20 is part of proper dividers but because "sum of some or all of proper divider" =20 (1+4+5+10).

Here is not semiperferct number
32=1+2+4+8+16
32-16=16
16-8=8
8-4=4
4-2=2
2-1=1 Not 0 (zero) so it is not a pseudonumber.

monarchmk 24 Junior Poster in Training

@desert564
Even if you try non stacked way, i think, you could not do it with one variable. LastOpen would help only if brackets are in order [].If you had several different oppening you will know only how many opened brackets by type are, but not which one is last. After first closing bracket you will have lastOpen=null for the rest of code. So either stack-liked method or array to keep track of all brackets.

@Taywin

I don't know why you need equalsIgnoreCase() while these strings won't be 'case' anyway...

I do not know either :), it is problem with speeding instead of "(" i click on "I" so Eclipse choose wrong template proposal :).I see it but was already too late to correct it.

monarchmk 24 Junior Poster in Training

I just copied your code in my eclipse and it works without any change.

did you by any chance get this error (package naming problem)

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
	at convDev.main(convDev.java:42)
monarchmk 24 Junior Poster in Training

@satti

This user is obvious example why is this thread written. I really try to help anyone but this one does not even want to stay online to check solution.
http://www.daniweb.com/forums/announcement8-2.html

monarchmk 24 Junior Poster in Training

@mKorbel thanks for pointing out... FileReader accepts "File" types..
Here is a loop with correct properties...

File folder=new File("C:\\"); //Open folder
	String[] flist=folder.list(); //Declare array and fill it with list of files
		for (int i=0;i<flist.length;i++) //Now go throught file list and...
		{
			System.out.println(i + ": " + flist[i]); // ... print their names. Here in format "FileNo: FileName". Change it as you need
			File f=new File("C:\\" + flist[i]); //!!!Be aware of folder path!!!
			if (!f.isDirectory())
			{
			FileReader ft=new FileReader(f);
			....
			....
			....
			}
		}

Ok, now line 9 should be place to continue with code...

monarchmk 24 Junior Poster in Training

@jon.kiparsky As i stated in previous post... if you say that before or sent an pm it would not be a problem

monarchmk 24 Junior Poster in Training

OK, calm down... as you can see in other my post... all codes are restricted.. or breaked apart, this one however i try to break apart but i lost my self in explanation and thats why i had to put all of it here. And its not reps that is important, i'll have bunch of ++ in not time thats not a problem... but please learn to ask before you judge!

monarchmk 24 Junior Poster in Training

Ugh...
do not have time to rewrite your code but a wrote a loop that you need for all files in folder

import java.io.*; // class File belongs here
...
...
...
		File folder=new File("C:\\"); //Open folder
		String [] flist=folder.list(); //Declare array and fill it with list of files
			for (int i=0;i<flist.length;i++) //Now go throught file list and...
			{
				System.out.println(i + ": " + flist[i]); // ... print their names. Here in format "FileNo: FileName". Change it as you need
			}

now join this code in yours and change file name for reading in flist and that should be it.

If this solved your problem, please mark thread SOLVED, if not i'll be glad to answer any of your question abaout my solution

monarchmk 24 Junior Poster in Training

First build an array of numbers...

String [] numbers=new String[13];
	numbers[0]="zero";
	numbers[1]="one";
	....
	....
	....

After array read input line from whatever device you need...
and declare one more string to handle new text like this...

String text=keyb.readLine();
	String newtext=text;

now make a loop thought all of array

for (int i=0;i<numbers.length;i++) {}

and here are some conditions involved..

if (text.contains(numbers[i]))
{
	newtext=newtext.replace(numbers[i],numbers[i+1]);
}

Rest is System.out.println,... for printing newtext

If this solved your problem, please mark thread SOLVED, if not i'll be glad to answer any of your question about this solution

monarchmk 24 Junior Poster in Training

Let hope that someone will not rep me - again for dropping solution
Anyway it was pleasure doing this one :)

public class parenthesis {

	public static void main(String[] args)
	{
		//Next ones are several strings just for testing. Only one should be active in a time
		String s="{([]{()})}"; //should be true
		//String s="{[]}(}"; //Should be false
		//String s="[]{{{}"; //Should be false
		//String s="[]{{}{}}"; //Should be true
		//String s="(((})))"; //Should be false
		//String s="((({})))"; //Should be true
		//String s="{{{}}}}"; //should be false
		
		String [][] par=new String [s.length()][2]; //Make array with length of a string s and 2 spare position for parenthesis and used/unused state
		boolean valid=true; //Lets be positive from start...
		
		for (int i=0;i<s.length();i++) //First will fill array with parenthesis
		{
			par[i][0]=s.substring(i, i+1);
			par[i][1]="0"; //means not yet used
		}
		
		for (int i=0;i<s.length();i++)
		{
//Check [ parenthesis
			if (par[i][0].equalsIgnoreCase("]")) //Checking for [ ]
			{
				//means there is closed  parenthesis.. check previous if there is opened one of same type and not already used
				//also check if previous is opened one but from other type, this is also invalid
				for (int j=i-1;j>=0;j--)
				{
					if ((par[j][0].equalsIgnoreCase("[") || par[j][0].equals("{")|| par[j][0].equals("(")) && par[j][1].equals("0")) //Check if previous parenthesis is open one of any type and not used one
					{
						//OK, i have open parenthesis... now check type. Valid is only if opened one match with closed one...
						if (par[j][0].equals("[")) //If previous is open and is right type then 
						{
							//OK, i need this type...
							par[j][1]="1"; //MAke it used
							par[i][1]="1"; //Make closed parenthesis used
							//I …
jon.kiparsky commented: If rep matters to you, quit doing people's homework for them. +0
monarchmk 24 Junior Poster in Training

You basically try to find if any of error list are equal or not equal to 0
Then put some sumerr integer and get sum of all errorLists...

int errsum=0;
for (int j=0;j<errorList.length;j++)
     errsum+=errorList[J]; // i'll make sum of all  errorList.If some of ErrLists are != 0 then sum is != 0

//Now check if sum is or not is equal to 0

  if (errsum ==0)
  {
    break; //you want to break if all are equal to 0you code if equal
  }
  else
  {
    //Your code if not equal
    for(int i=0; i<row; i++)
    {
        initialWeight[i] = newWeight[i];
    }
  }
monarchmk 24 Junior Poster in Training

This is simple sales... now show us that you are willing to participate in development of your homework so we can help you further

For codedown you need only a Form and CommandButton (named Command button 1)

Private Sub Command1_Click()
Dim qty As Double
Dim partno As String
Dim price As Double

partno = InputBox("Which partno do you want to sale", "Sales", 0)
qty = InputBox("Please Enter quantity for partno " & partno, "Sales", 0)
price = InputBox("Please Enter Sales price for " & qty & " pcs of " & partno, "SAles", 0)

MsgBox "You bill is " & Chr(13) & partno & " " & qty & " x  " & price & Chr(13) & _
"                    " & Round(qty * price), vbOKOnly, "Sales"

End Sub
monarchmk 24 Junior Poster in Training

No, now we had discussion...MrHardRock does not escape with his homework. He is trying to learn something now... :)

@MrHardRock. On a first look, seems like that but...
There are some constructional differences. I'll try to point them in next several lines :)

1) Biggest difference is in a way of filling arrays.
Here is sample how you fill arrays... For example Let say user input 4 numbers: -1 1 2 5

After 1st Number array are

Your way

NEG[0]=-1               
EVEN[0]=null
ODD[0]=null

after 2nd number

NEG[1]=null 
EVEN[1]=null
ODD[1]=1                

after 3rd number

NEG[2]=null
EVEN[2]=2               
ODD[2]=null

After 4th number

NEG[3]=null
EVEN[3]=null
ODD[3]=5            

So at the end you have arrays like this

NEG[0]=-1   EVEN[0]=0   ODD[0]=0
NEG[1]=0    EVEN[1]=0   ODD[1]=1
NEG[2]=0    EVEN[2]=2   ODD[2]=0
NEG[3]=0    EVEN[3]=0   ODD[3]=5

And the Result will be

Negative Numbers are -1 0 0 0 
Even Numbers are 0 0 2 0
Odd numbers are 0 1 0 5

This is not correct. Problem is that when you try to fill arrays, you have one counter (i) and that why you endup with bunch of 0's in all arrays.1 counter does not allow you to fill every array in order. Instead you have chaotic ordering of values in arrays.
You here need to implement counters for each of number types. It is easier and faster way of programming with arrays.

Normal way

NEG[0]=-1
EVEN[0] and ODD[0] are not jet used...

after 2nd number

ODD[0]=1 …
monarchmk 24 Junior Poster in Training

:)
I agree that this could be a problem, but if that guy is willing to know JAVA he can learn a lot from code by comparing my with his code and learn from his mistakes.If his intend if just to solve his homework, then no searching in this world will make him learn anything.
And please do not rep--; me if you do not like my way of helping someone. Judge my knowledge. Thanks

monarchmk 24 Junior Poster in Training

Here is my view of your code... I added some comments so you can use it.
and some BIG suggestion... If you planning to continue to use JAVA learn how to indent your code... putting that much {{{}}} in same starting point (column1) is too much confusing and not readable. Look down in my code to see difference. It is simple for start... on every opened parenthesis add one TAB more.
Also arrays starts from 0, why do you start counters from 1? i thing that the problem why you create array with 11 fields.I leave it like that in code below but every other thing i started from 0, just not to be confused.

import java.io.*;

 public class evenodd
{
  public static void main (String [] args) throws Exception
	{
	  BufferedReader reader=new BufferedReader(new InputStreamReader(System.in)); //I preffered Bufferedreader, you can change it
	  double[] even=new double[11]; //Declarations
	  double[] odd=new double[11];
	  double[] negative=new double[11];
	  double number=0;
	  int ceven=0; //Counter for even values
	  int codd=0; //Counter for odd values
	  int cneg=0; //counter for negative values
	  
	  for (int i=1;i<9;i++)
	  {
		  System.out.println("Please input your number");
		  number=Double.parseDouble(reader.readLine()); //Converting string to double as you want doubles
		  if (number < 0) //If number is negative...
		  {
			  negative[cneg]=number; //... put it in negative array and..
			  cneg++; //increase negative counter by one
		  }
		  else if (number % 2 ==0) // if number is even  notice that checking is with % not number/2!=0
		  {
			  even[ceven]=number; //put it in array
			  ceven++; //increase even counter
		  }
		  else if (number % …
jon.kiparsky commented: Please don't do his homework for him +0
monarchmk 24 Junior Poster in Training

Can you please share some more of your code, as db and rs definition?
Type of database..
Did you clearly define recordset as ADODB.recordset or DAO.recordset...?
If in preferences is DAO in priority of ADO db type then you could receive this type of error.

monarchmk 24 Junior Poster in Training

Try this code... Error was my mistake when you call a sub with () there must be = sign... So now i called without (). You have comment in changed lines 27, 38 and 48.
Unfortunately i can not check code on work since i work in linux... but it should work ok this way

This is solution to send separate mail to every employee. If you need to send only one mail to all employees then use @AnderRet sollution above.

Private Sub Form_Load()

folder = Dir("c:\LogBook\*.txt") 'variable folder conatins names of files in folder c:\LogBook\ with extension *.txt
    While Len(folder) <> 0 'loop while length of folder is 0 which means no file found...
        List1.AddItem Left(folder, InStr(folder, ".txt") - 1) 'add file to list, but trim .txt extension..
        folder = Dir() 'read again
    Wend

End Sub

Private Sub Picture2_Click()

Dim IDs As String

For i = 0 To List1.ListCount - 1 'do loop within all od list1 indexes
    If List1.Selected(i) Then 'If checked index is selected then ...
        filename = "c:\LogBook\" + List1.List(i) + ".txt" 'Construct filename, add folder and extension
        Open filename For Input As #1 'Open file for reading
        While Not EOF(1)
            Line Input #1, LineA 'Since all dates are same i will read only 1st row
        Wend
        Close #1 'Close file
            If DateDiff("d", CDate(Left(LineA, 10)), Now()) > 2 Then 'If difference between now and readed date is more than 2 days ("d")
                ''IDs = IDs & "ID " & List1.List(i) & " IDFrom" …
monarchmk 24 Junior Poster in Training

Hi again :)

Mulitple select is possible with this 2 rows

list1.list(list1.listindex) is selected line from list1
list2.list(list1.listindex) is line in list2 but in position where is list1.

also this can be implemented in above routine in this place (rows 23-26)

If DateDiff("d", CDate(Left(LineA, 10)), Now()) > 2 Then 'If difference between now and readed date is more than 2 days ("d")
        IDs = IDs & IIf(Len(IDs) > 0, ",", "") & List1.List(i) 'Add id to listbox. You can construct this info how do you like
        sendmail(list2.list(i),"subject","body") 'In this line where IDs are joined you can sent mail. list2.list(i) is because i is row identifier here. Also list1.list is used with variable i
     End If

now in position of row 33 of your code add this 2 statements

EXIT SUB

Public Sub SendMail(Optional EmailTo As String, Optional Subject As String, Optional Body As String)

Now some explanation whats happening... As you are using my code for IDs, all ID's are grouped together FOR ...NEXT cycle in rows 15-28. with this cycle i go threw all listbox1 items to check if they are selected and if they are then i add them to simple string sield for later display. But in your code in line 41 .To = personel.List(List1.ListIndex) you get email address from user in position of last row that you are selected in list1 prior to clicking a command button. Thats why i break you procedure in 2 (line 33 with end sub) and add …

monarchmk 24 Junior Poster in Training

@AndreRet Thanks :)

@TheDoctored - Even when it is offTopic, i already provide you with solution of your 2 problems in my answers. You have parts of solution how to synchronize both listboxes and solution about muliple IDs and only one mail :). however, open new topic so we will solve that issue

monarchmk 24 Junior Poster in Training

that correct but he goes threw loop in list1 (multiple IDs can be checked) so somewhere in loop will be good place to put a call to sendmail routine...

this below is part of my previous code, if you using it you can modify it or if you use another code, thisi is only to give you idea where to put calls...(see red line with comment)
This part use your routine for sending mails, i call sendmail with all parameters so both will work together

...
...
...
Private Sub Command1_Click() 'After selecting id's in listbox, you will click on command button 1, this is procedure
Dim IDs As String


For i = 0 To List1.ListCount - 1 'do loop within all od list1 indexes
    If List1.Selected(i) Then 'If checked index is selected then ...
        FileName = "e:\vbtest\" + List1.List(i) + ".txt" 'Construct filename, add folder and extension
        Open FileName For Input As #1 'Open file for reading
             Line Input #1, LineA 'Since all dates are same i will read only 1st row
        Close #1 'Close file
            If DateDiff("d", CDate(Left(LineA, 10)), Now()) > 2 Then 'If difference between now and readed date is more than 2 days ("d")
                IDs = IDs & IIf(Len(IDs) > 0, ",", "") & List1.List(i) 'Add id to listbox. You can construct this info how do you like
                 [b]sendmail(list2.list(i),"subject","body") 'In this line where IDs are joined you can sent mail. list2.list(i) is because i is row identifier here. Also list1.list is used with …
monarchmk 24 Junior Poster in Training

If i understand correctly.. list1 and list2 are aligned (item X on list1 is item X on list2??) then it is not a problem.

list1.list(list1.listindex) is selected line from list1
list2.list(list1.listindex) is line in list2 but in position where is list1.

monarchmk 24 Junior Poster in Training

No.. Error handler in Excel when you are using FIND command return nonsense error.
Problem is with Excel search engine. Runtime error 91 is bassicaly "no cells containing searched value". selection.find itnernal error ahndler makes mistake. I've used FIND in a lot of Workbooks with VBA and everywhere when i forgot Error handler, i received same error.

Problem that @otomatis had when search works with fixed text and does not work with variable is probably due to extra spaces in textbox or formatin a while FIND syntax. As otomantis never publish here full selection.find i can never tell if it is complete ok. For start I wrote that there is extra parenthesis.
I sumulated whole situation with excel and vb code and everything work as i suggested above in previous post. Only error handler is problem and one parenthesis.

Here is my VB Code. Just make one workbook wiht several filed cells and try it for your selfs.

Private Sub Command2_Click()
Dim mailmwo As Excel.Application
Dim mwoBook As Excel.Workbook
mwonum = Trim(txtscan.Text)

Set mailmwo = New Excel.Application
mailmwo.Visible = True
mailmwo.Workbooks.Open "C:\asus\book1.xls", , , , "", ""   ''Change path and Workbook name to keep it simple
mailmwo.Worksheets("Sheet2").Select

mailmwo.Sheets("MWOs - Do Not Sort!").Select
mailmwo.Range("A1").Select
Debug.Print mailmwo.Range("A1").Value
'Notice, After mwonum variable there is no parenthesis
'With this coding you will receive Runtime 91 
'If you add following code everythig will work!
'ON ERROR RESUME NEXT    'NEW CODE
mailmwo.Selection.Find(What:=mwonum , After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, …
monarchmk 24 Junior Poster in Training

Difference between tooltip, textbox or any similar text control is almoust none...
They all look almost same.
I see problem on other side. You can not control where is current(active) row in listbox and you cannot position any controls below or inline with active row.

As for tooltip VB does not have any tools that could change any property of it. And also in VB tooltips are not show if there is no mouse involved.