Comatose 290 Taboo Programmer Team Colleague

When you say "all I want it to do" seriously trivializes what you want to do. I built a program that does voice recognition, but you have to make sure that you install the microsoft voice recognition software, and after that, you have to "train" the voice recognition software (it takes some kind of algorithm with your voice and sets itself to function based on the way you talk). I believe the sdk is: http://www.microsoft.com/downloads/details.aspx?familyid=7D13964C-06FD-4BF9-B49C-814FAA6A86EA&displaylang=en
once you get what you need installed and running, let me know, and I can give you the code I used.

Comatose 290 Taboo Programmer Team Colleague

Let me know how it turns out...

Comatose 290 Taboo Programmer Team Colleague

It sounds to me like a completely fresh install of XP is the best solution to this problem. I'm sure it's not the only solution, and hopefully someone who does this a lot more often than I do (tracking down windows system errors) can help you more in depth than I can, maybe DMR, nanosani, or nizzy.

I would suggest a reinstall, but it sounds to me like there is something wrong with the registry (I'm brought to this because you downloaded divX, and it wouldn't run properly, and I'd guess that it's bundled with all the files it needs).

Sorry I couldn't dig further into this for you.

Comatose 290 Taboo Programmer Team Colleague

A Good Debugging Technique, is to add msgbox's throughout the code. So, add one right at very beginning that says "start" and then just after an if block, or something like that. That will give you a reference point, so that you can say "ok, well I got to this point, and then it errors out", and that will help to give you a better idea where the error is at. object variable or with block variable not set is a pretty standard error message meaning that an object is missing a reference... so this should give you a pretty good idea as to what is going on (once you use the msgbox's to figure out where in the code you are).

Comatose 290 Taboo Programmer Team Colleague

mkay... and what line does it highlight?

Comatose 290 Taboo Programmer Team Colleague

Welcome.

Comatose 290 Taboo Programmer Team Colleague

does it highlight or give you a line number?

Comatose 290 Taboo Programmer Team Colleague

I'm guessing this is XP and those were found in c:\windows\system32?

Comatose 290 Taboo Programmer Team Colleague

I agree, I too am fairly suprized that this information can't be retrieved, but you imagine how many times you open a folder or file, that's a lot of time-stamps, and could take a lot of hard-drive space saving all those logs. I realize it can just time stamp them with text, which isn't a huge space hog, but it could certainly add up if you open and close a folder quite a bit.

Comatose 290 Taboo Programmer Team Colleague

Can you find the .dll files that it's complaining about on your hard-drive? For example, if you do a start, search (or find), files and folders, and look for those names, are they found?

Comatose 290 Taboo Programmer Team Colleague

I hate to say it, but I don't believe that you can. I think the most you can hope for is check a file's properties, and look for the Last Accessed Time, but this is only for files, and doesn't pertain to folders (and my last accessed time is off anyway, it says it's been accessed last some time in the future....) There are programs around that can keep this information for you in the future, but windows doesn't store this information to my knowledge.

Comatose 290 Taboo Programmer Team Colleague

What version of windows is this.... what version of messenger is this, and how many other people use msn messenger on that computer? Do you have trayserver running?

Comatose 290 Taboo Programmer Team Colleague

Daniweb Code Snippits To Save The Day:

http://www.daniweb.com/code/snippet36.html

Comatose 290 Taboo Programmer Team Colleague

Right, And not having a good understanding of what your variables are doing (defining them certainly helps with that) leads to real nasty code, and triples your pain in debugging.

Comatose 290 Taboo Programmer Team Colleague

I just built a program that goes through an entire hard-drive, and makes the Icon of the .lnk file the same as the program that it points to. You can feel free to download, install, and distribute it at will, so that this can be prevented in the future (if not prevented, easily fixed.). Be aware, that it doesn't fix where the shortcut points to (your post says that all the icons opened something else, it does not fix that) but after you uninstalled all the icons were messed up.... this program will fix the messed up icons. Anyway, here is the link:
http://www.aftermath.net/~coma/Tools/iconfix.zip

Comatose 290 Taboo Programmer Team Colleague

Thumbs up to Yomet on this one. Nice code, and good way to redirect focus back into the forum instead of to his e-mail. Well Done.

Comatose 290 Taboo Programmer Team Colleague

I have been coding VB since windows 3.1, and to be perfectly honest, I've never used an option explicit. In most cases I don't actually declare it with a full layout, (perhaps my Qbasic days kicking in) but more times than not, I use the symbol identifiers (this is in my own code, since most modern day programmers would get too confused by the symbol identifiers). I just find it easier to say:

dim words$

Less Typing and if you know that $ is the symbol for string, it's more clear throughout the rest of the code as well. Also, if you happen to be a big API Fan (Like myself) the API will take dump on variables passed to it, that are not of the proper type.... again, this helps the layout of the API Call (using variable identifiers) because you see what you are passing into the function. For example purposes, I don't declare them usually or even identify them (variables) because it's not code that's going into production, but for code that I release, or code that is built for a company, for the sake of speed and the avoidance of memory leaks in code, I make sure that every thing is declared.

In fact, for those reading who are interested:

$  = String
% = Integer
& = Long
! = Single
# = Double
Comatose 290 Taboo Programmer Team Colleague

Absolutely! Just to ensure I Built a Quick Test Program:

Private Sub Form_Load()
Dim X(2)
X(0) = "hi"
X(1) = "bye"
X(2) = "end"

For Each word In X
    MsgBox word
Next word
End Sub

Works Great. I was amazed too, after having coded Perl for some time, I found myself using for each's in VB, and correcting myself to using ubound.... and one day I said "hmn..." and it worked. Saved me a lot of pain. Just for future reference, you can use it on collections and Arrays.

Comatose 290 Taboo Programmer Team Colleague

:) thanx for that Dani.

Comatose 290 Taboo Programmer Team Colleague

Good Job Finding that. I knew the answer, but you responded before I got here. Well done.

Comatose 290 Taboo Programmer Team Colleague

Welcome Aboard, and hopefully you make your stay a long one. ;)

Comatose 290 Taboo Programmer Team Colleague

http://www.daniweb.com/tutorials/forum68.html, there should be a button on the bottom for contribute tutorial (the link is for VB Specifically).

Comatose 290 Taboo Programmer Team Colleague

The function you are looking for is "Command", which will retrieve any parameters passed to the program. I don't quite seem to recall if the program needs to be compiled (made into an exe) before it will work in your code... but a here is a small example that should display everything passed to your program:

msgbox command$

Yeah, That's Right, it's just that simple. Then you can run a test on the passed command function with a select case or even a simple if. It becomes slightly more complicated when you want to read more than 1 command line argument, because the entire command line is passed to command$ as a string, so if you wanted to do something like:

yourproject.exe /width=10 /height=10 /nosound

Then you would have to rip apart the command line by each space, and work with them accordingly. A Real easy solution to that is to use split to gather each item into an array like so:

dim Args() as string
Args = split(Command$, " ")
' /* Now Args Is An Array Containing Each Item */
for each Arg in Args
     msgbox Arg
next Arg

Hope this helps, and let me know the outcome.

Comatose 290 Taboo Programmer Team Colleague

Well, Firstly, the slashes should be the other way.... I know in later versions of windows it understands both, but if you run it on a box that is earlier versions of window, most likely ME or 98, it will get pretty upset with you. The keyword to check if a file exists, is "dir", and you can use it to check for wildcards as such:

Dim Fname As String
Fname = Dir("c:\program\*.id", vbNormal)
While Fname <> ""
    MsgBox Fname
    Fname = Dir
Wend

That will only msgbox (popup) the names of all the files ending in .id in the c:\program directory.... if you want to Search The Entire Hard Drive, you can do that too... let me know if you have any further questions.

Comatose 290 Taboo Programmer Team Colleague

in a code module:

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Sub OpenWith(ByVal xFileName As String)
    ShellExecute 0, vbNullString, "RUNDLL32.EXE", "shell32.dll,OpenAs_RunDLL " & xFileName, "", vbNormalFocus
End Sub

And then wherever you want to show it:

call openwith("somefile.txt")

Let me know how it turns out.

Comatose 290 Taboo Programmer Team Colleague

First problem (in form_load):

me.show
main.Setfocus

Second:
Dunno which box we are talking about... the big multi-line one?

Third (on text1's keypress event, or whatever box you do the typing in):

if keyascii = 13 then
     keyascii = 0
     main.text = text1.text & vbcrlf & main.text
end if
' /* Or Something Like This ^ */
Comatose 290 Taboo Programmer Team Colleague

tmpvar is a temporary variable, used only as a buffer to hold the current line of the file in the loop. Basically, it gets changed on every line of the file. It's only used as a temporary storage place to store the item long enough to stick it into the collection. Truth be told, you could probably read the data directly to the collection, but it makes it easier to read the code using the buffer variable. I'm guessing somewhere you have an option explicit set, which is demanding you declare all your variables... try removing the option explicit, and see if that resolves anything.

Comatose 290 Taboo Programmer Team Colleague

Nope, Yomet's Right.

Comatose 290 Taboo Programmer Team Colleague

The Melee.txt text file should have 1 entry per line for the code above to work. So, something like:

knife
dagger
spear
elbow

The dir function is telling me if the melee.txt file exists.... the vbnormal portion of it, says to look for a normal file, with no hidden, or system attributes set. Imagine our pain if you did an open command and the file wasn't there..... uh oh.

Comatose 290 Taboo Programmer Team Colleague

Sure it is.... try this in a test project on form_load:

' /* Declare A New Collection */
Dim Melee As New Collection

' /* Add Item Dagger, with index of: dagger */
Melee.Add "Dagger", "dagger"
' /* Add Item Sword, with index of: sword */
Melee.Add "Sword", "sword"

' /* Show By "key" index */
MsgBox Melee.Item("sword")

' /* Show By Numeric Index */
MsgBox Melee.Item(1)

Now, you can do this with some files that read it in.... hmn, something like:

dim meleeFile as string
meleeFile = app.path & "\melee.txt"

' /* If The melee file does Exist */
if dir(meleeFile, vbnormal) <> "" then
     open meleeFile for input as #1
          do until eof(1)
               input #1, tmpvar
               melee.Add tmpvar, tmpvar
          loop
     close #1
end if

And now, whenever you want to add a melee weapon or something, you can just update the .txt file (hmn, you could let the user make their own weapons and stuff now.... cool). Obviously, these are just two examples, but I'm sure you can figure out how to make them work together...

A little on collections:

Collections can be referenced by either a numeric index, or a keyed index. Naturally, the first index say, melee.item(1), would be the first item in your collection list. melee.item(2) the second and so on. You could also reference it by the key name. In the first snippit, you see "Sword" which is the actual value, you could get that from using melee.item(2), but you …

Comatose 290 Taboo Programmer Team Colleague

I would suggest putting these skills into a data file, like a text file, or a database. I might strongly suggest that you look into SQL or ADO (you'll find that you will have less trouble with SQL) for this project. I, however, would go with text files (because I don't always listen to reason). Then, you read in the textfiles, say, on form_load, and use a dynamic multi-dimensional array. I Can See Redim Preserve playing a big role in this. You might also consider using a "collection" instead, which is sort of like an array, but with keywords as indices. Let me know what you come up with.

Comatose 290 Taboo Programmer Team Colleague

I think it needs a full url

Comatose 290 Taboo Programmer Team Colleague

I know that the API is a fun place to play around, but you should really consider using windows scripting for that task....

dim NewValue as string
dim WSH
set WSH = createobject("WScript.Shell")
NewValue = "Whatever you want CD Quality's Value To Be"

WSH.regwrite "HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Audio\WaveFormats\CD Quality", NewValue, "REG_SZ"

set WSH = nothing

Post Edit: Sorry, I was reading it in a hurry, the CD Quality's key is NOT a string (REG_SZ), it's a binary or Hex... I'll keep digging around and let you know what I find.

Comatose 290 Taboo Programmer Team Colleague

it seems to me like you will need to calculate the height of the shape. So something like

if shape1.top = 8000 and (shape1.top - shape1.height) = 6000 then
      msgbox "yup"
end if

But remember, it might be shape1.top + shape1.height, depending on how you are looking at it, because the screen starts 0,0 at the very top left and then gets bigger going down and to the right. Here is a program's source that I wrote for a friend of mine that lets him put the mouse in a given point on the screen, and while it's in that given area, it disables the screen saver

Comatose 290 Taboo Programmer Team Colleague

Sure,

The function is simply "Time", but it comes in a specific format. You can use the format function, to specify the format the time returns for example:

dim CTime as string
CTime = format(time, "h:mm:ss")
if CTime = "22:25:00" then
   msgbox "it's 10:25pm"
end if

If you research the format and time function, you can have it set for 24 hour time, or 12 hour time, and you can specify how many digits per part of the time. Then just compare and execute :) Keep in mind, however, that you would want to put this in a timer control, and set the interval to either 1 second or 100Milliseconds (I use 100ms, but every second would work just as well), the timer control's interval property works in Milliseconds, so 1 second would be 1000ms. Also, remember to disable the timer, or set a flag variable after the time hits, and the program runs the commands, otherwise, it will continue to run those commands over and over again until the time is no longer (in this case) 22:25:00. Let me know how it turns out.

Comatose 290 Taboo Programmer Team Colleague

Actually, The second and third link refers to the .NET platform, which would be vb.net. This particular forum is for Legacy Versions of VB (Mostly VB6). He also says that he's new to Visual Basic 6, and so the syntax in .NET would be of no help to him. But Thumbs up on the references.

Comatose 290 Taboo Programmer Team Colleague

I'm still slightly confused... a for loop in and of itself is a counter, but umn, the error is in your syntanx, it should look something more like:

for I = 1 to 5
     for J = 1 to I
          ' /* Do Stuff Here For Your Printing  */
     next J
next  I

If you want to maintain the indents when you post code, you can stick them in [ CODE ] [/ CODE ] Tags (with no spaces).

Comatose 290 Taboo Programmer Team Colleague

*Thanks Narue*

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

Or You go power user, and use sockets to connect to the mail server and send the message using the protocol defined in the smtp rfc: http://www.ietf.org/rfc/rfc0821.txt.

That's how I'd go about it ;)

Comatose 290 Taboo Programmer Team Colleague

Yup.

You set the objects back to nothing (destroying them) before you ever use them in the code:

Dim oXL As excel.Application
      
      Dim oWB As excel.Workbook
      Dim oSheet As excel.Worksheet

      Dim bolExist As Boolean

      Dim strCell_Value As String
      Dim i As Integer
      
      Dim num_cells As Integer
      
      
    Set oSheet = Nothing
    Set oWB = Nothing
    Set oXL = Nothing

You need to use them to do the reading or writing to excel BEFORE setting them to nothing. ;)

Comatose 290 Taboo Programmer Team Colleague

The character codes for that are vbcr and vblf (also vbcrlf) which translate to chr(13) and chr(10) (those are carriage return and line feed). So, if it would be easier for you to merely check for an occurance of either of those in a string using instr, and replacing the offending character with the replace function, that might be an easier solution for you. However, if you want to leave the file completely unchanged, and merely write the file as it is with binary:

Dim B() As Byte
Dim srcFile as string
dim destFile as string

' /* Change This To your File */
srcFile = "c:\somefile.exe"
destFile = "c:\destination.exe"

Open srcFile For Binary Access Read As #1
     ReDim B(LOF(1) - 1) 
     Get #1, , B
Close #1

open destfile for binary access write as #1
     put #1, , B
close #1

Let me know what you come up with.

Comatose 290 Taboo Programmer Team Colleague

I will say that the C/C++/Javaish/Perlish/etc/etc structure for working with escape sequences is a real treat compared to The basic language. The only way to do this, is to concantenate the character code value to the string where the double quote would be. It's sick, and it makes the code a lot less understandable when dealing with strings, but here is how your example would look:

str1 = "President Lincoln said " & chr(34) & "Four score and seven years ago..." & chr(34)

chr is the basic function to return the ascii value of a given character code. In this case, 34, which is ". This page has a cool list of them: http://www.lookuptables.com/

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

Are you sure this belongs in the VB forum?

Comatose 290 Taboo Programmer Team Colleague

Hmn, Maybe your code post your project in a .zip, or post the code that is relevant to each problem?

Comatose 290 Taboo Programmer Team Colleague

;)

Comatose 290 Taboo Programmer Team Colleague

Hmn, I get an invalid zip file.... maybe upload it again?

Comatose 290 Taboo Programmer Team Colleague

First thing is first, you have to declare an object variable for the excel object, and then you have to instatiate an instance of the excel object. You should also consider creating an object to the workbook in the excel document. It would start off looking something like this:

dim objExcel
dim objWorkbook

Set objExcel = CreateObject("Excel.Application")
' /* obviously, you need to change "c:\path\yourfile.xls" to your excel document */
Set objWorkbook = objExcel.Workbooks.Open("c:\path\yourfile.xls")

Then, you can choose which Sheet (ya know, the tabs at the bottom) you want to work with, with a call to Select, like this:

objExcel.ActiveWorkbook.Sheets(1).Select()

Then, you can read and write to cells in the document, by referencing them by row and column, so, you could set a variable to the data in row 2, column 1 like this:

CellValue =  objExcel.Cells(2, 1).Value

And similarly, you can write to the excel document in just the opposite way, like this:

objExcel.Cells(2, 1).Value = "hello"

And no matter what, when you are done using the excel document, it's a very important point to make sure that you set the object references to nothing, like so:

set objExcel = nothing
set objWorkbook = nothing

Here is a pretty good site to help you through understanding how you can work with excel in VB, reading data, and writing data: http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=315, if you need any further assistance with this, let me know.

Comatose 290 Taboo Programmer Team Colleague

Hmn,

Strangely enough, the questions that I answered actually were posted! It looks as if he must have edited the thread (or someone else did), and changed the original post :eek: . Strange.