Comatose 290 Taboo Programmer Team Colleague

it's not a good idea to use sleep. Sleeping may always wait (in this case) 1 second, but some machines may take longer than 1 second to load the prompt. Basically, you are having to guess how long it will take that window to appear, and shoot in the dark at an approximate range. I suggest using a findwindow API call, and put yourself in a do loop.... say, do until the return value of findwindow is not 0, then sendkeys to the window.

Comatose 290 Taboo Programmer Team Colleague

Attach your project.

Comatose 290 Taboo Programmer Team Colleague

Right. Something else you'll need to take into consideration is the size of the image. If you set it to be auto-size (the picture or image control) then it will change depending on the size of the picture.... if you don't, it will chop off the image so you can't see it all. Now, you could use an image control instead of a picturebox control, and set it's stretch property to true, which will shrink the image (or whatever) to the size of the image control, BUT it doesn't render the image with any kind of decent quality. When I wrote a picture viewer, I made a seperate form that was used as the viewer pane, and resized the entire form to a given ratio based on the size of the picturebox, so that way it didn't seem too flawed. Good luck with your project.

Comatose 290 Taboo Programmer Team Colleague
System.Runtime.InteropServices.Marshal.ReleaseComObject (xlSht)
System.Runtime.InteropServices.Marshal.ReleaseComObject (xlWBook)
System.Runtime.InteropServices.Marshal.ReleaseComObject (xlApp)

will not work in vb6. That, too, is vb.net. In order to have the excel.exe application close from the process list, you are going to need to SET the objects to Nothing. Just like you set the objects to something (be it a workbook, or excel.application, or whatever), you have to then set it back to nothing. One thing about programming (in any language) that I truly love, and that is a pretty strict rule, is that "Anything That You Open, You Must Also Close." Now, while it may not seem that creating an object is the same as opening one, it is. If you do an if statement, what else must you do? You must End If, if you while you wend, if you do you loop, if you open you close, if you create, you destroy.

set xlSht = nothing
set xlWBook = nothing
set xlApp = nothing
set xltmp = nothing
Comatose 290 Taboo Programmer Team Colleague

Yes, Form_MouseMove, when I double click the form, I change the combobox on the top left to mouse_move, the declaration is:

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

End Sub

and here is where I went:

Comatose 290 Taboo Programmer Team Colleague

I dunno why you can't set the tooltiptext property, but what you do is set the value BACK or to whatever it was previously, in the mouse_move event of the form. For example, I built a program that has "hyperlinks" on a tab control. All it is, is a blue label with the mouse move, mouse down, mouse up and click events set to different things. In the form's mouse_move, I just have it set all the labels back to their original color and what not.... you can do the same for your super-tooltip.

Comatose 290 Taboo Programmer Team Colleague

Eeewww good luck with that!

Comatose 290 Taboo Programmer Team Colleague
Comatose 290 Taboo Programmer Team Colleague

That's something you have to do internally to your windows machine though (which rocks for me, but not for someone trying to do it through a web page... now if we can find out where that same type of key is for firefox).

If I'm not mistaken, you could use a DIV with some crazy CSS (to hide and show the div) with an absolute positioning, set the oncontextmenu to a function (which shows the div, and returns false for the actual context menu), but the context menu has things that you can't make happen within a page.

but I seriously agree with tgreer, screwing with people's interface is a bad idea.... 9 times out of 10, if a page is messing with things I don't think it should be, I'm gone. I won't stay there. I don't even like pages playing music, or embedding objects (like media player) when I first navigate there. Now, I've done this before (made a page which replaces the context menu), but I made it a choice in preferences, and I made it disabled by default (meaning, in order to use my div menu, they had to consciously go in and turn it on), and beyond that, I made an option in the DIV for "Standard Menu" so when they clicked that, it would load the normal context menu the next time they clicked.

If you feel absolutely drawn to having to affect the users interface, words of wisdom say to …

Comatose 290 Taboo Programmer Team Colleague

I do remember previously that there was discussion (I believe in the moderators forum at the time) about people who use Daniweb as part of their resume, and there was a big hype about changing the unknown quantity, wasn't there?

I don't personally mind either one (the stars, or the unknown quantity) I just remember having more stars, and couldn't see why I was being semi-demoted ;)

Comatose 290 Taboo Programmer Team Colleague

*Nods* Makes sense.

Comatose 290 Taboo Programmer Team Colleague

Wow, you are on top of it :)!

Now about them stars....

Comatose 290 Taboo Programmer Team Colleague

Is it just me, or does this happen to anyone else (just started today). I've cleared all my history and cache, and cookies from firefox, and did a hard-reload, and it's rendering it this way.... Idea's *Cough*Dani*Cough*

And how did I lose stars? I had 4, I'm down to three???

Stars--;?

Comatose 290 Taboo Programmer Team Colleague

oops, fixing it, standby (I just realized that str2Array uses Mid, that's kind of a conflict of idea's, huh?)... just replace the old str2array with this one:

Public Function str2Array(xString As String) As String()
Dim tmpArray() As String
Dim B() As Byte
Dim tmpchar As String

B() = xString
For I = 0 To UBound(B) Step 2
    spush tmpArray, Chr(B(I))
Next I

str2Array = tmpArray
End Function

Basically, it assigns the string to a byte array. The byte array contains numbers instead of letters, but the numbers directly coorispond to the letters, so we use chr with the character code to get the letter. We push that onto our array, and then return it to the calling procedure. This method is actually a lot faster than using the mid function (with larger amounts of data), because it doesn't have to make a bunch of copies of the string, AND it's working with bytes.

Comatose 290 Taboo Programmer Team Colleague

There are a couple of ways to tackle this problem. I would personally make a function that splits the string into an array, and then grab the passed number as that array's indice. I have attached a project that has 3 functions in it. The first I'll go over is str2Array, which takes each character in a string, and puts it into an array, 1 character per indice. The str2Array function requires the use of another function, spush (String Push), which just sticks elements onto an array, like a stack. It simplifies having to deal with dynamic arrays by rediming every time you want to add a new element to the array. The last is the actual mymid function, which takes 2 arguments (the string, and the starting point), and an optional 3rd argument, which is the length to return to the calling procedure. Something to note about this function, is that it too, just like the actual Mid function, returns the entire rest of the string if the length passed to it is greater than the end of the string. So, for example, if the string is "hello world", and you tell the function to start at character 6, and go a length 15, it will just return world, and not error out. A serious difference, though, (which can be fixed fairly easily) is that the actual Mid function reads the first character of a string as 1, while the mymid function starts …

Comatose 290 Taboo Programmer Team Colleague

Nope, that's for .NET, which doesn't apply. Imports doesn't work in Legacy Vb's. However, setting the objects back to nothing is the proper way to go about this. Otherwise, you'll have tons of exe's (as objects) just floating around and eating up Ram.

Comatose 290 Taboo Programmer Team Colleague

That's 24 hour format right? 12 is noon, and 0 is midnight.

Comatose 290 Taboo Programmer Team Colleague

*Mumbles Something about VBScript And ActiveX*

Comatose 290 Taboo Programmer Team Colleague

We appreciate all the help we can get, certainly, I just want to avoid having people trying to build something in one language get further complicated by examples for another.

Comatose 290 Taboo Programmer Team Colleague

Ok, this is a vb 4, 5, 6 forum, not a vb.net forum. Should you be looking for that forum, you can find it here: http://www.daniweb.com/techtalkforums/forum58.html. var.tolower() is a .net method, and is not available in vb6. Let's try to keep related information grouped in their respective forums.

Comatose 290 Taboo Programmer Team Colleague

Yeah there is.

Comatose 290 Taboo Programmer Team Colleague

Right, and to take it a step further most SQL servers don't support it (again, my note on it being server specific) and if I remember correctly, the SQL92 Rules obsolete the use of it.... however, for people who do a lot of programming, the slash is a tradition, and so long as the server supports will use it (since we are giving off a lot of information in this thread, figured it's good knowledge).

Comatose 290 Taboo Programmer Team Colleague

It's my personal opinion that, that much information should be done in seperate databases.... even seperate apps, but I'm not here to judge, I'm here to help... so I suggest using sockets. I would personally build a server program to handle the database, the database would sit on 1 computer, along with the server. You make the server program handle any and all work with the database. This helps to avoid problems with synchronizing later on.... since only 1 user (the server application) ever makes changes or updates to the database. You make the server program work in such a way that if client A is writing to the database, that client B has to wait until client A is done, and vice versa. If you have the proper amount of bandwidth, you can leave the client programs connected to the server all the time, and if you are in need to conserve bandwith, you could have the clients connect when they make an update.

Another solution, which I'm not so fond of, is to have each client app work directly with the database, and have the database on a network drive. You'll find serious issues with bottlenecks and speed, and may even lose your mind because of it, but it's a solution people have been toying with for some time..... like beating your head on a brick wall, in hopes you'll tear it down... I guess maybe someday it could happen.

Comatose 290 Taboo Programmer Team Colleague

Ah yes, filler. Honestly, I'd like to be able to mark this thread solved, because I know that I have a lot of questions in this forum regarding vb and databases. In fact, the sticky thread at the top of this forum is about vb and access.... if you decide to write a tutorial or something along those lines, we can link to it, so that other people get resolutions too.

Comatose 290 Taboo Programmer Team Colleague

Just a note, on some SQL Server implimentations, you actually can escape the ' character (and any other) just like in C and Perl, so the statement:

INSERT INTO [ItemTable] ([ItemName]) VALUES ('Bob\'s shades');

would also work, but that is server specific. As for hackers, it's pretty common knowledge that a hacker uses flawed programming to gain access and/or execute remote code.... I certainly appreciate posts with as much knowledge as possible, I just have a hard time seeing how that relates.... I suppose in order to fix the problem that Sul has posted, we need him/her to post the entire sql statement, and the information relevant to it so that we can go from there. I would imagine, however, since the statement works in access and not in VB, that it's a port problem from access to VB and has nothing to do with the SQL statement.

Comatose 290 Taboo Programmer Team Colleague

Yup that makes sense. environment.newline doesn't work in vb4, 5, and 6 (it does in .net, but that's a language I could do without). Since both of us are approaching this from different sides (Mine from a VB standpoint, yours from the SQL standpoint) Are you seeing a problem with the SQL Statement that would need to have escaped quotes?

Comatose 290 Taboo Programmer Team Colleague

You could use sendkeys.

Comatose 290 Taboo Programmer Team Colleague

No, VB would flip it's lid. You can't escape characters in VB, it just doesn't work that way, so you have to use the chr function in order to represent those values outside of the string. Since this isn't a java forum, it's not pertinent to the discussion, so escaping is not available. You would need to concantenate the Statement in the variable, like so:

' double quote
dq = chr(34)
x= dq & "hello there" & dq

Which would make a field blank, since it's not being passed anything but 1 parameter.... which is the string itself.

Comatose 290 Taboo Programmer Team Colleague

In VB, I'm sure the problem has more to do with the fact there are variables in the SQL statement, that are inside of quotes.... making the variables a literal string. For example:

X = 5
msgbox "x"

Does NOT produce a msgbox of 5..... it performs a msgbox of the letter x. I'm thinking the problem is the same.

Comatose 290 Taboo Programmer Team Colleague

Hmn, that might require a server side language.

Comatose 290 Taboo Programmer Team Colleague

Best way is to use a server side language, like Perl or PhP (or ASP), and use it for the authentication...

Comatose 290 Taboo Programmer Team Colleague

just stick an if in the code...for example:

($hr, $min, $sec) = split(/:/, $timevariable);

if ($hr eq "24") {
     $hr = "00";
}

$timevariable = "$hr:$min$sec";
Comatose 290 Taboo Programmer Team Colleague

Sure. I'd be glad to help.

Comatose 290 Taboo Programmer Team Colleague

Variants are a Data type... just like string, integer, long, etc. Actually, a variant lets VB decide what kind of data type to make it. It even allows for some change in the variable type. It's a bulky variable, and really is not good programming practice, because it will bulk your code. Not to mention that no other programming language in the world (including VB.NET) supports this type of behavior. For each uses variants, because you can for each through an array of any kind of data in the world you want. The array can be integers, or strings, or longs.... makes no difference. So the control variable (the one that represents the element of the array in the loop), has to be of a type that VB can choose on a whim. If you do a for each on an array of strings, then the control variable will be a string..... if you do a for each on an array of integers, then the control variable will be integer... My suggestion is to only use them though, when VB requires to.

Comatose 290 Taboo Programmer Team Colleague

I forgot to declare it.... just stick it up at the top with the other dim's... define it as string. (You use option explicit, which forces you to implicitely declare your variables.... I don't.)

Comatose 290 Taboo Programmer Team Colleague

Glad to have tried to help.... if you could have posted that information previously, I would have done a better job. Sorry for the miscommunication.

Comatose 290 Taboo Programmer Team Colleague

This doesn't actually change it in the file.... but it writes a new file, you can just easily change the variable on the second open to be the file it read from, however. I'm sure that Rashakil or Narue will show you a much more effecient method, but for now this works:

#!/usr/bin/perl

$timefile = "times.txt";
$newfile = "newtimes.txt";

open(FH, "$timefile");
        while (<FH>) {
                chomp;
                ($tm, $pod) = split(/ /, $_);
                ($hr, $min, $sec) = split(/:/, $tm);
                if ($pod eq "PM") {
                        $hr = $hr + 12;
                        $tm = "$hr:$min:$sec";
                } else {
                        $tm = "$hr:$min:$sec";
                }

                push @new_times, $tm;
        }
close(FH);

open(FH, ">$newfile");
        foreach $ntime (@new_times) {
                print FH  "$ntime\n";
        }
close(FH);
Comatose 290 Taboo Programmer Team Colleague

like this in the file: 12:12:00? or like this: 12:12? Or like this: 12:12:00am?

Comatose 290 Taboo Programmer Team Colleague
#!/usr/bin/perl

($sec, $min, $hour, @junk) = localtime(time);

print "$hour:$min$sec\n";
Comatose 290 Taboo Programmer Team Colleague

I had written a long explaination... but power went out, and computer rebooted..... and I'm not re-writing it. Basically, I introduced "dynamic arrays" which are just like normal arrays, but they can change size, by using the redim keyword. We set the array to be the same size as the listbox, we take everything in the listbox, stick it in the array, sort the array, clear the listbox, and put the sorted information back into the listbox....

Comatose 290 Taboo Programmer Team Colleague

Not even a little. If I had Admin privs in this forum, I'd squash you.

Comatose 290 Taboo Programmer Team Colleague

why not use cookies?

Comatose 290 Taboo Programmer Team Colleague

:(

Comatose 290 Taboo Programmer Team Colleague

You'll need to use the windows API with Pascal...I found this site: http://www.irietools.com/iriepascal/progref305.html, but it's about Irie pascal and not turbo pascal.... I'm not sure the difference. Basically, you need to figure out how to call functions of the windows library's (the windows dll's) with pascal. Then you can use the exitwindows or exitwindowsex API call.

Comatose 290 Taboo Programmer Team Colleague

Regardless of how nice visal's is ;), I'm going to post new code that works on dates regardless of their format. This is still a bubble sort, but it uses a niffty built in Date module, and calls the datediff method. Date diff returns a number (in either days, years, etc, depending on the first parameter), and compares 2 dates, and returns the difference (in our case, in days) between them. This removes the need for you to add a module, and it also significantly lowers sort time, because there is only 1 nested for loop, and not 3. I'm keeping the Swap function, but I'm sticking it in the form, instead of in a module (to be honest, I like the swap function). Just so you are clear, it loops through each element, just like before, and compares it to each element, but it uses the datediff function, then it checks if the datediff function, returned a negative value (it checks for -, meaning negative of course). If the value returns negative, then we swap the elements of the array. If you want to sort this backwards, so that smallest is on top (or, earliest rather), then just replace the = to a <> in the if statement, and it will sort them the opposite direction... Here is the project.

Comatose 290 Taboo Programmer Team Colleague

Creative Visal, and Well done.

Comatose 290 Taboo Programmer Team Colleague

it should work correctly..... all I did was take the nested for loop for months, and move it above the nested for loop for days, so instead of:

Dim I As Integer
Dim X As Integer
Dim IDay As String
Dim XDay As String
Dim IMonth As String
Dim XMonth As String
Dim IYear As String
Dim XYear As String

' /* Sort By Order Of Days*/
For I = 0 To UBound(DList)
    For X = 0 To UBound(DList)
        IDay = Left(DList(I), 2)
        XDay = Left(DList(X), 2)
        If XDay < IDay Then
            Call Swap(DList(), I, X)
        End If
    Next X
Next I

' /* Sort By Order Of Months */
For I = 0 To UBound(DList)
    For X = 0 To UBound(DList)
        IMonth = Mid(DList(I), 4, 2)
        XMonth = Mid(DList(X), 4, 2)
        If XMonth < IMonth Then
            Call Swap(DList(), I, X)
        End If
    Next X
Next I

' /* Sort By Order Of Years */
For I = 0 To UBound(DList)
    For X = 0 To UBound(DList)
        IYear = Right(DList(I), 4)
        XYear = Right(DList(X), 4)
        If XYear < IYear Then
            Call Swap(DList(), I, X)
        End If
    Next X
Next I

I made it:

Dim I As Integer
Dim X As Integer
Dim IDay As String
Dim XDay As String
Dim IMonth As String
Dim XMonth As String
Dim IYear As String
Dim XYear As String

' /* Sort By Order Of Months */
For I = 0 To UBound(DList)
    For X = 0 To UBound(DList)
        IMonth = Mid(DList(I), …
Comatose 290 Taboo Programmer Team Colleague

Crap, I see that, when I get home from work, I'll work on switching around the dates.

Comatose 290 Taboo Programmer Team Colleague

Ok, to start, the line: Public Sub B2S_BSort_Date(DList() As String, LBox As ListBox), creates a public subroutine. You can create these on a whim just because you feel like it. They are user defined subroutines. You have to 2 kinds (well, a lot more in VB) of procedures. Subs and functions. These are sort of like mini-programs. Things that you will do in your code a bunch of times, but you don't want to bulk it out by copy and pasting the same code blocks over and over. So you just make a sub that does it once, and you call it whenever you need to. The name of the sub, B2S_BSort_Date, is Big To Small (B2S) Bubble Sort Date. When you call this sub (just like any other sub you would call, like print, or whatever) you have to give it information. In the case of this sub, we are passing it 2 "parameters". The first, is an array, and the second is a listbox. An array is a single variable, that can contain more than 1 value. So, for example, you can have variable X, and variable X at position 0 or X(0), can equal one thing... while variable X at position 1 X(1) can be something else altogether. The only restriction is that they be the same type (if X is integers, then all of them have to be integers). In this case, the variable that our sub expects is a string, containing dates in the form …

Comatose 290 Taboo Programmer Team Colleague

You'll have to do quite a bit of modification in your code to impliment this, since you already have it loading data and everything.... you'll need synchronized arrays to keep all your data in order, but here is a module I wrote that does bubble sort on dates, in either direction. The date format must be in the order of: dd/mm/yyyy. There are 3 functions, 2 are the bubble sort, and 1 (should be private, but what the hey) that is used to swap the elements to the respective indices. The 2 bubble sorts are: B2S_BSort_Date, and S2B_BSort_Date, which is Big To Small Bubble Sort, and Small To Big Bubble Sort Respectively. Based on the image you posted, you could easily modify the portions of the bubble sort in the nested loops that gather the portions of the date to work with your data without too much splitting.... but here is the project, and I wish you the best of luck.