Comatose 290 Taboo Programmer Team Colleague

C# IS .net. It's just a C style usage of it.

Public Function GetInstalled()
        Dim uninstallKey As String
        Dim rk As RegistryKey
        Dim sk As RegistryKey
        Dim skName As String
        Dim sublist As New ArrayList

        uninstallKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

        rk = Registry.LocalMachine.OpenSubKey(uninstallKey, True)

        For Each skName In rk.GetSubKeyNames()
            sk = rk.OpenSubKey(skName)
            sublist.Add(sk.GetValue("DisplayName"))
        Next skName

        Return sublist
    End Function

EDIT: Sorry, Didn't Refresh The Page Before Posting...

Comatose 290 Taboo Programmer Team Colleague

That's Really Great Work. Not only did you solve your own issue, but you also showed us a valid, and clean way to do it. Great Job pG.

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

I would do it something like this:

Dim File2Find As String
Dim FileList() As String
ReDim FileList(0)
Dim wsh
Set wsh = CreateObject("WScript.Shell")
File2Find = "somefile.txt"

Open "c:\quickrun.bat" For Output As #1
     Print #1, "@echo off"
     Print #1, "cd \"
     Print #1, "dir /a/s/b " & File2Find & " >c:\found.dat"
Close #1

wsh.run "c:\quickrun.bat", 0, 1

If Dir("c:\found.dat", vbNormal) = "" Then
     MsgBox "hmmm... something isn't right"
     Exit Sub
End If


Open "c:\found.dat" For Input As #1
     Do Until EOF(1)
        Line Input #1, chk
        If chk <> vbNullString And chk <> vbNewLine Then
            If UBound(FileList()) > 0 Then
                ReDim Preserve FileList(UBound(FileList()) + 1)
                FileList(UBound(FileList())) = chk
            Else
                FileList(0) = chk
            End If
        End If
     Loop
Close #1


If Dir("c:\quickrun.bat", vbNormal) <> "" Then Kill "c:\quickrun.bat"
If Dir("c:\found.dat", vbNormal) <> "" Then Kill "c:\found.dat"

For Each xFile In FileList()
    If xFile <> vbNullString Then
        MsgBox xFile
    End If
Next xFile

MsgBox "Done"
Comatose 290 Taboo Programmer Team Colleague

You should be able to just specify the entire path and file name as the parameter.

Comatose 290 Taboo Programmer Team Colleague

Sure, but your if statement is looking for if(tfgame.ToggleWarhead == True) which from what I can tell is not the name of your class. Unless I've been living in *nix too long, and case doesn't matter any more: class TFGame extends xTeamGame;

Comatose 290 Taboo Programmer Team Colleague

Set AutoCompleteSource to ListItems, then set AutoCompleteMode to whichever one you like. I prefer Suggest, but you can check them all to see which one is ideal for you.

Comatose 290 Taboo Programmer Team Colleague

just for kicks and laughs, let's try to replace the (or just below the line of) 'msgbox line with Application.Doevents(). I've noticed that sometimes when a msgbox makes code work that doesn't seem to work without it, a Doevents is the right medicine. Let me know if it works or not.

Comatose 290 Taboo Programmer Team Colleague

Post the code that you have already (for the open and write sections)

Comatose 290 Taboo Programmer Team Colleague

What do you mean search a file? Are you trying to make a program that the user can type in a search text, and it will find the file name? or will it find that phrase/word /INSIDE/ the file?

Comatose 290 Taboo Programmer Team Colleague

For Top Level:

MsgBox(ListView1.SelectedItems(0).Text)

And Subitems:

MsgBox(ListView1.SelectedItems(0).SubItems(1).Text)

You may want to make sure you have subitems before trying that one ;)

Comatose 290 Taboo Programmer Team Colleague

Well.... I don't see when the destructor would be called.... that is, does a second new mean a call to the first destructor? I don't think so... because destruction happens when the object is set to nothing, or it goes out of scope... and neither one is happening. You are simply assigning the object variable to a new instance of an object... and the first object is not set to nothing, nor is it going out of scope... If the idea though, that when the object no longer has the variable pointing to it that it gets destructed can be tested...so I did a for loop from 0 to 1000, and basically just put in it strBldr = New StringBuilder("a", 2).. If the destructor gets called when strBldr no longer points to it, then the application shouldn't consume more memory (maybe temporarily while it's swapping stuff around, but not permanently). Then I opened up Windows Task Manager, and sorted the list by memory usage. Then I clicked the button with the for loop in it, a few times... and sure enough, the memory usage of the EXE kept growing more and more each time I did it. (I made the initial strBldr variable public, in the class scope... so it was declared at the top :) ) So to answer your question.... probably.

Comatose 290 Taboo Programmer Team Colleague

Well, the first step in any perl app when using the dbi interface is to make sure perl knows to use it:

use DBI;

Then, you want to make perl connect to the database using the DBI interface, so, make a variable and assign it to a database connection:

$dbh = DBI->connect("DBI:mysql:users", "Username", "Password");

In this code, we connect using DBI to a mysql database, named users. We also supply the username and password to access the database.
Now, we need to create a query, and execute it:

$query = $dbh->prepare("SELECT username from dba_users where username like '%I3598%';");
$query->execute();

And finally fetch the information we want:

while ($tmpname = $query->fetchrow()) {
     push @dba_usernames, $tmpname;
}

Now, (assuming all the assumptions I made about the type of database, the name of the database, and the name of the tables/columns are accurate) you should have an array called dba_usernames, that contains a list of all the usernames that match your query.
Now, simply display them if you want (though, you could probably do this in the while loop instead for efficiency.. but this lends itself to future growth):

foreach $name (@dba_usernames) {
     print "$name\n";
}

You may have to tweak it a little, to work exactly how you like, but this should at least get you knee deep on the right path.

Comatose 290 Taboo Programmer Team Colleague

What version of windows are you using?

Comatose 290 Taboo Programmer Team Colleague

Is There a masked textbox control on there?

Comatose 290 Taboo Programmer Team Colleague

Not to distract from your original question (ie: how to run commands from perl) but, if accessing a database is what you want to do, why not simply do so directly from Perl, using say.... The DBI Module?

Comatose 290 Taboo Programmer Team Colleague

Certainly. The possibility that an API call, for example, that worked in XP was modified to a different datatype or even name under Vista. Ultimately, I'd need to see the code (at least, the portion of the program that craps out) in order to be able to figure out for sure. I would personally install XP in a virtual machine and see if it works normally, if so, you can bet it has to do with Vista.

Comatose 290 Taboo Programmer Team Colleague

Hmn, I've had a similar experience, but I found I was able to rename the Shortcut by searching for the text in the registry, and then renaming the REG_SZ. The ClassID (long goofy numbers and letters) will likely be different on your machine, but on my XP home the key/value was found here: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{871C5380-42A0-1069-A2EA-08002B30309D}, and simply renaming the (Default) Value To My desired text worked.....

Comatose 290 Taboo Programmer Team Colleague

Yeah, We aren't going to do your work for you..... if you need help, that's one thing.

Comatose 290 Taboo Programmer Team Colleague

Maybe he means build a POS (Point of Sale) Register, Something for teachers to keep track of student's grades, and averages, or something for a hospital, where patience sign in, receive medical care (which gets documented into the DB) and gets discharged....

Comatose 290 Taboo Programmer Team Colleague

A Timer is a control, just like a button, or an option button or some other fun little tool.... here is a little article: http://www.vbdotnetheaven.com/Code/Jun2003/2084.asp You can have it run a function at set intervals....

Comatose 290 Taboo Programmer Team Colleague

Is this in XP (there has a been a few threads going around about problems with reading/writing serial ports in XP with VB). Also, I'm not sure if the output is supposed to be a string, or if it's supposed to be those values in hex.....

Comatose 290 Taboo Programmer Team Colleague

This was a bit of a toughy for me...

The If Statement will never be true (it will always run the else) because the trim function returns a string. Period. (Actually, that's only partly true, it returns a Variant of subtype String, but for all intents and purposes, it's a string). Since it returns a string, isnull will never return true, because even if there is nothing in the passed value, trim will then return an empty string (not a null string) and therefore, won't be null.... so, I figured I'd remove the trim statement. Still wouldn't return true for me.... then I realized that you declare the variable in the header of the function as a string.... which, automagically (when created) makes it an empty string. Even if you pass it a null value.

The final solution I found (after trying a myriad of other things) was to change the type declaration to a variant in the function header, and to pass it "null" (not vbnullstring (which is a string), and not vbnull (which is a long)). This successfully returned a true from that if block. Here is how I modified the code:

Public Function Field2Str(strValue As Variant) As String
  If IsNull(strValue) Then
      Field2Str = " "
    Else
     Field2Str = Trim(strValue)
  End If
End Function

and I called it like this retval = Field2Str(Null) . I'd also like to point out that your function doesn't return an empty sting if the value is null, it actually …

Comatose 290 Taboo Programmer Team Colleague

Can you tell us what the solution was?

Comatose 290 Taboo Programmer Team Colleague

I'm not 100% sure I know what you are asking.... if I'm missing the mark completely, let me know.... are you looking for an "elseif" type command?

Comatose 290 Taboo Programmer Team Colleague

Let strsql = "SELECT * from bids where bidno ='" & temp & "'" is not the solution, try something like: strsql = "SELECT * from bids where bidno = " & chr(34) & chr(34) & temp & chr(34) & "'" & chr(34) EDIT: Nevermind, I totally missed the mark on that one! :eek: try something like this (I don't know what bidno is supposed to be, either an integer, or a long, or a double, or what): Let strsql = "SELECT * from bids where bidno ='" & cint(temp) & "'"

Comatose 290 Taboo Programmer Team Colleague

Which version of VB are you using firstly? Is it VB6? Also, what is webform.vb? Is it a project file that you made in visual basic?

Comatose 290 Taboo Programmer Team Colleague

I might not understand you completely, but if you are asking what I think you are asking, setting a global variable should work among all forms. I just want to make sure that you are using VB6, and not VB.Net or VB express..... Because I don't believe VB6 has a GlobalFunctions Object.

Comatose 290 Taboo Programmer Team Colleague

I want to give a thumbs up to Yomet here.... Keep up the good work.

Comatose 290 Taboo Programmer Team Colleague
retval = inputbox("type stuff")
if retval = "" then 
    ' /* Cancel Pushed, Or Left Blank */
    msgbox "You Entered Nothing..."
else
    ' /* They Typed Stuff */
    msgbox retval
end if
Comatose 290 Taboo Programmer Team Colleague

Nothing that is readily, so to speak. You may have a look at bitblt or stretchblt to copy pieces of the image, but as for the whole region selection issue, I have no pre-defined method. Good luck, let me know what you find.

Comatose 290 Taboo Programmer Team Colleague

It's a problem with my code (BAH):

if right(SearchString, 1) = chr(13) or right(SearchString, 1) = chr(10) then
     ' /* Should be Left, Not Right */
     SearchString = left(SearchString, len(SearchString) -1)
end if
Comatose 290 Taboo Programmer Team Colleague
if right(SearchString, 1) = chr(13) or right(SearchString, 1) = chr(10) then
     SearchString = right(SearchString, len(SearchString) -1)
end if

Would Also Do The Trick... There's more than one way to strip a newline (ok, that one's bad).

WolfPack commented: Done. +3
Comatose 290 Taboo Programmer Team Colleague

That is the best way to do it. A couple things I would note on this. One of them, is the use of an empty string in the replace function. I know on small applications, that it doesn't make a serious difference, but an empty string uses memory space (well, more than a null value). A Character holds (I believe it's) 8 bytes. A Null Value holds like 1, or 2. So, in really big VB applications, changing "" to vbnullstring can speed up the app (benchmarks show by 40%) by using vbnullstring instead of "". So, you could redo the function as SearchString = Replace(SearchString, Chr(13), vbnullstring) to perform the same action, and save RAM usage. Again, I know this isn't extremely important, especially with modern machines, but it's good to know, and a nice practice to have.

The other thing, and I'm not sure if this is the intended result or not, but the above code will remove ALL chr(13's) from the string, not just the trailing one (when reading files, it's usually not a problem, since input will separate lines by newlines as it's read in, but a lot of apps that I have built require reading a file (or from a socket) 1 character at a time). An alternative method, if you are just wanting to remove the trailing newline, would be to use the left function SearchString = left(SearchString, Len(SearchString) -1) .

I'm sure that the replace function is a fine solution for …

WolfPack commented: Useful points there. +3
Comatose 290 Taboo Programmer Team Colleague

why can't you do it on mouse_move? On mousedown set a boolean flag variable that says that the mouse is down. On mouseup clear the boolean flag variable (set it to false). On the mousemove procedure, check if the flag variable is true, and if so, draw the line..... if the flag variable is false, don't draw the line.... or am I completely missing the mark here?

Comatose 290 Taboo Programmer Team Colleague

For those of us (myself included) who have been tracking this thread.... what was the solution?

Comatose 290 Taboo Programmer Team Colleague

I can't really tell by your code, but is this VB express, .NET, or Legacy (VB 4, 5, or 6)? If it's Legacy VB, could you attach the project in a .zip to your next post, so that I can download your code, and see your problem. The truth is, I can't even replicate your error. I'm guessing, since vb6 doesn't have a .checkstate property for checkboxes, that it's not VB6. Something to check, and I see (based on your question) why you would have done this, but you are testing the checkboxes .value property against an empty string (""). Something to consider, would be testing against vbnull or vbnullstring.

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

lover's method is accurate, and will work.... however, it's not good programming style. As Waltp Mentioned, it's easier first off, to reference the object hierarchy, and beyond that, why would you want to use memory space (a variable) to contain information that's ALREADY stored somewhere? That will slow down the program (more processing, and memory usage) and make code a bit more difficult to read....

Comatose 290 Taboo Programmer Team Colleague

I wouldn't suggest going about it that way. You can add a textbox to the form, and set it's "multiline" property to true. Then go to the "scrollbars" property, and choose if you want vertical, horizontal, or both. They will only be active when the data goes beyond the textbox, and basically works as you would expect.

Comatose 290 Taboo Programmer Team Colleague

Good Job Here Agrothe (Andrew)

Comatose 290 Taboo Programmer Team Colleague

I'm not 1000% sure I understand what you are asking.... I'm guessing you have an MDI form as like a remote control or controller (navigation) window, and when you do something in that window, you want it to display the corresponding MDI form..... BUT that MDI form COVERS your remote right? Do you have the MDI form that covers the remote set to maximized?

There are probably 2 solutions here (assuming I have the correct problem). One is to set the MDI Navigation Form to "always on top", so that even if the other form covers it, it's Z-order will remain the same. The other solution, would be to not have the secondary forms (the one's that cover the navigation form) set to maximized, but rather, normal. Then on it's form_load (or resize, or whatever), have some code in there to ensure that the me.left is never less than the remote forms .left + .width .... let me know if I'm off course here or not.

Comatose 290 Taboo Programmer Team Colleague

WaltP is correct. You can also call functions, events and methods this way too. For example, if you have a button on form2, and you want to "click" it from a button on form1, you can do something like form2.command1 = true .

Comatose 290 Taboo Programmer Team Colleague

Can you attach the project to a post, or e-mail it to me (in a .zip [e-mail is in my profile]) so that I can have the pictures and everything needed for this to run?

Comatose 290 Taboo Programmer Team Colleague

If I'm not mistaken (yeah, sometimes, but not frequently ;) ) this should work:

Fname = Application.GetOpenFilename
With ActiveSheet.QueryTables.Add (Connection:="TEXT;" & Fname, Destination:=Range("A1"))
end with

Now, I've tried the code, and maybe my excel VBA Coding is a bit rusty... but I don't get it loading into any cells that way. I think the file will have to be opened through code, read in, and put into the cells..... but let me know if the above works for you, and maybe I can figure out why it doesn't for me :eek:

Comatose 290 Taboo Programmer Team Colleague

Is this a homework project? If so, what are the specs? what have you done so far? What do you need help with?

Comatose 290 Taboo Programmer Team Colleague

Does it compile though the IDE (without the use of the package and deployment wizard)?

Comatose 290 Taboo Programmer Team Colleague

Thanks for following up the solution.... it's a great help for others following and having the same problem.

Comatose 290 Taboo Programmer Team Colleague

Is the database (or any part of it) password protected?

Comatose 290 Taboo Programmer Team Colleague

Ah sure.... assuming it was VB.net that logic would make sense.... but we are in Legacy VB ;)

Nice code, by the way. It's elegant, and tasteful.