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

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

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

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

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

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

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

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

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.

monarchmk 24 Junior Poster in Training

Dear Sir,

Thanks for replying sir, "LstName" is the name of pop up menu. In my previous thread also some respected member suggested to use label. But my requirement is not that actually. I think i will not get the appropriate answer here. Any way, thank you once again sir.

giving up so easy?...

What about TextBox? If you do not like Label, use TextBox. If you make it property Flat(appearance=0) and BorderStyle=0 (none) it will look same as PopUp. Even with standar settings looks almost same as PopUp. Down you can find same code for textbox control with your measurements for position same as PopUp. Even you can select text or parts of text inside.

And if must be PopUp, there must be some specific reason. Let us hear it, maybe if this could not be solved with popup, We can try find similar control for you!

Private Sub List1_KeyUp(KeyCode As Integer, Shift As Integer)
    If Len(List1.Text) > 1 Then
        Text1.Text = List1.Text
        Text1.Width = Len(List1.Text) * 200
        Text1.Height = 400
        Text1.Left = List1.Left + List1.Width / 2
        Text1.Top = List1.Top + List1.Height / 2
        Text1.Visible = True
    Else
        Text1.Visible = False
    End If
End Sub
AndreRet commented: Nice suggestion. +7
P.manidas commented: I will use it sir +3
monarchmk 24 Junior Poster in Training

easy :)

replace line 18 (Line Input #1, LineA)
with this code

While Not EOF(1)
              Line Input #1, LineA 'Since all dates are same i will read only 1st row
        Wend

it will loop until it is end of File (EOF) 1 in parenthesis is index number of file that you opened in line 17.

And please mark thread SOLVED if everything is OK.

monarchmk 24 Junior Poster in Training

Ok..

You need,
One Listbox named List1.In property of ListBox please change MultiSelect to 1 (as it is readonly in runtime so i could not change it in code)
One CommandButton named Command1
and this code... (put it in form code, Code replaces FORM_LOAD and COMMAND1_CLICK procedures) If you have procedure for filling list1, do not use mine, use only parts that you need.

Private Sub Form_Load() ' On form loading do...
folder = Dir("e:\vbtest\*.txt") 'variable folder conatins names of files in folder e:\vbtest\ 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 'End of form load


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) > …
monarchmk 24 Junior Poster in Training

Ok, here is some sample code...

You need
Listbox (in sample ) List1
Command button Command1 in sample just for activating
For Path I used C:\###.txt - Please Change in Line 11
Date parser is in row 15 but it is just sample, i do not know date format that you are using
And i still does not have a clue what to display in msgbox :?:

Private Sub Command1_Click()
Dim DateA()
Dim DateRow As Integer
ReDim DateA(List1.ListCount)

DateRow=1

For I = 0 To List1.ListCount - 1

    If List1.Selected(I) Then
        FileName = "c:\" + List1.List(List1.ListIndex) + ".txt"
        Open FileName For Input As #1
        Line Input #1, LineA
        Close #1
        DateA(DateRow) = Left$(LineA, 10) ' This is sample for date parser ...
        DateRow = DateRow + 1
    End If

Next

'Now here you have
'DateRow - how much dates you have
'DateA() - dates retreived from files...
'You can use 
'For i = 1 to DateRow
'     msgbox DateA(i)
'next
'or something like this :)
End Sub
monarchmk 24 Junior Poster in Training

What you need to be displayed in MessageBox?
Is date same for every row in file?
Is the location of all files in same folder?
Format of the date? dd/mm/yyyy or dd-mm-yyyy or dd,MMMM YYYY or similar? example maybe?

When you check ID's, you will get dates of every ID and then what would you lake to be done with those dates?

monarchmk 24 Junior Poster in Training

You have existing list1 and lstName. by properties that you use, I think lstName is label. If you can use that or any other label, please check following code
On every list1 item that is longer than 18 characters it will show label above list1. And hide it if length is < 18 characters.
Some of the code inside this procedure (like width. height of label) is not intend to be here but for sake of the sample i must use it this way.

Check is this works for you...

Private Sub List1_KeyUp(KeyCode As Integer, Shift As Integer)

            'lstName.Caption = List1.Text
            If Len(List1.Text) > 18 Then
                lstName.Caption = List1.Text
                lstName.Width = Len(List1.Text) * 100
                lstName.Height = 300
                lstName.BorderStyle = 1
                lstName.Left = List1.Left
                lstName.Top = List1.Top - lstName.Height
                lstName.Visible = True
                lstName.ZOrder (0)
            Else
                lstName.Visible = False
            End If
                
End Sub
monarchmk 24 Junior Poster in Training

If it is a length problem, why not you use a Frame (empty captioned) with label inside (only label can not be put in front of listbox)? There is much less complications.

monarchmk 24 Junior Poster in Training

If my list box item is too long, and that is not visible in my list box because of list box width.

Then, you want to put all invisible (items out of bounds of list box) items in popup menu?

If this is point, why not put columns in list box?

Also how big will be popup window?
popup and List-box sizes are almost same size, so i do not thing that you will gain space using popup and not enlargeing listbox. Except on small forms.

debasisdas commented: Very good point. +7
monarchmk 24 Junior Poster in Training

glad to help :)

monarchmk 24 Junior Poster in Training

I need some clarification...
Pop up menu show when you push up/down arrow in listbox?
What is the point of using Popup when you already see item in list?
Also Popup menu is kind-of modal form, out of focus turns visible to off

monarchmk 24 Junior Poster in Training

I do not understand, you need to search while hdd for file and than open it or just single folder? Solution up is for single (known) folder and for partial filename. You can use any name with wildchars like DIR("e:\MyFile2???.txt") or DIR(e:\MyFile2*.txt")

monarchmk 24 Junior Poster in Training

If i understand correctly... This is loop with DIR function thru all files in folder names MyFile2*.txt (eg20001, 20002, 202 etc.)

MyFile = Dir("e:\MyFile2*.txt")
While MyFile <> ""
    Debug.Print MyFile 'Or do whatever you like with file... MyFile variable contain file full name
    MyFile = Dir() 'read new file if it exist... if not loop will end
Wend
monarchmk 24 Junior Poster in Training

Normaly i did not read whole syntax and wrote SQL for MS databases...
Correct syntax for Firebird is
SELECT FIRST 1 from rt_time ORDER BY <orderfield> DESC

this should solve issue (i hope:) )

monarchmk 24 Junior Poster in Training

select top 1 * from rt_time order by ID DESC

You can change ID in whatever column which is criteria for last record (eg. date, ordernumber...), and DESC means order from last to first, and top 1 means return only first record (which is last record in database with desc order).This passes job on server not on you software.
Also try put some indexes on lager tables, it will work faster

monarchmk 24 Junior Poster in Training

maybe in header cell you can put...
=IF(COUNTIF(B2:B8;"<35")>=2;"FAIL";"PASS")

where B2:B8 is range
"<35" is criteria for Fail...
CountIF(range,crit) gives number of cells in range which meets criteria