Comatose 290 Taboo Programmer Team Colleague

I created a macro designing a pivot table.
when i copy the code into the VB application the pivot table shows a count instead of a sum!!!

Any ideas why?

Cheers

Hmn, Post the relevant code?

Comatose 290 Taboo Programmer Team Colleague

It's called "incrementation." It's something that has been in programming for a very long time. Even as low level as assembly language, has a special opcode for incrementing variables (INC in asm). This is the process of simply adding one. So, if the value of count is 1, then after the count++ the variable count becomes 2. Higher level languages, such as BASIC (in all forms that I know of) do not use this method. You have to explicitly say: count = count + 1. Also, WHERE you put the ++ becomes important in some languages also. If you put the ++ after (count++) the variable name, then it adds 1 to the variable AFTER whatever condition is tested. If you were to put ++ BEFORE the variable (++count) then it would increment (add one) to the variable BEFORE the condition is tested. Hope that wild explanation has helped a little.

Comatose 290 Taboo Programmer Team Colleague

Nah, Not at all :)

Comatose 290 Taboo Programmer Team Colleague

I think if you store the ocx on a public drive, you can do a:

regsvr32 H:\Path\To\whatever.ocx

obviously H: would be the public drive. Have you tried putting on a public drive?

Comatose 290 Taboo Programmer Team Colleague

You're Welcome ;)

Comatose 290 Taboo Programmer Team Colleague

Are you double clicking on the form1, or are you opening visual studio, and then opening the form? There should be a project file (which is the name of the project.. project1)

Comatose 290 Taboo Programmer Team Colleague

Let Me know if this works for ya

dim fso
dim f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile("C:\boot.ini")

CreatedDate = f.DateCreated
LastAccessed = f.DateLastAccessed
LastModified = f.DateLastModified
FileSize = f.Size

msgbox "Created Date: " & CreatedDate
msgbox "Last Access: " & LastAccessed
msgbox "Last Modified: " & LastModified
msgbox "File Size: " & FileSize
Comatose 290 Taboo Programmer Team Colleague

Just Replace "commandname" with the path and exe that you want to run, and replace /a /b /c with any command line switches that you have.

dim wsh
set wsh = createobject("WScript.Shell")

wsh.Run "commandname /a /b /c", 0, 1
Comatose 290 Taboo Programmer Team Colleague

I can remain silent if you would rather.... my name says it all. :)

Comatose 290 Taboo Programmer Team Colleague

have you tried debugging it with an alert (to make sure the HTML is importing the script?) something like: alert("made it to such and such function"); and stick that in a function in the external.js file, and then in your HTML code, when you call the function (that is supposed to be in the external.js file) it should come up with an alert. This way, you know the browser is actually retrieving the javascript code.

Killer_Typo commented: pretty smart idea about checking to see if its even calling the script. +1
Comatose 290 Taboo Programmer Team Colleague

http://www.windowsitpro.com/Files/07/8389/Table_02.html
http://www.windowsitpro.com/Files/07/8184/Table_01.html

are links to a pages of numbers relevant to files and folders.... you just add. So, system, being 4, and hidden being 2, means setting attributes to 6 makes it system and hidden. 7 would be system, hidden, and read only. With folders, if base is 16, that would be the equivelent of 0. So 17 should be a read only folder. Let me know how things work with that script. I'm going to mark this thread as solved (I'm guessing the copy went over correctly). :)

Comatose 290 Taboo Programmer Team Colleague

As for searching the entire hard drive for .txt files, I have a solution for that. There a few different ways of accomplishing this task. One of the easiest (and most effecient) ways that I have found to get this done, is by shelling to DOS, and using it's old-timer fun. If you stick a little VBS in your VB Program, you can trivialize the searching process. Here is a little snippit:

dim wsh
set wsh = createobject("WScript.Shell")

open "c:\runme.bat" for output as #1
     print "@echo off"
     print "dir /a/s/b c:\*.txt >>c:\textpaths.txt"
close #1

wsh.Run "c:\runme.bat", 0, 1
kill "c:\runme.bat"

This code will create a DOS batch file. The batch file executes a dir command, with the /a/s/b switches. A little breakdown here, /a tells dir to show ALL files... hidden, system, whatever. /s is the switch to recurse into sub-directories (all folders). The last switch, /b is for "bare" which is simply... only show me the paths and filenames. Then, we make use of the redirection operators of DOS (the >>). A little about those, is that > means to over-write whatever file files, while >> means to append. So, the command in the batch file basically says, show me a list of paths and filenames to all .txt files, and store that information in the file "textpaths.txt".
Then, We use VBS to run the batch file. The reason I've chosen this method, is because the last trailing number (1) in the wsh.run method, actually tells WSH …

Comatose 290 Taboo Programmer Team Colleague

Ok, here is the modified VBS File (without any changes that you made to the other [since I don't have them]) so that it updates the boot.ini file, instead of copying it over from the memory stick. here is the modified VBS File in it's entirety:

' /* Declare Variables */
dim wsh
dim fso

' /* Get current App Path, And Drive Letter */
MyPath =  WScript.ScriptFullName
ThisDrive = left(MyPath, 1) & ":"

' /* Get Shell Object */
set wsh = createobject("WScript.Shell")

' /* Get File System Object */
set fso = CreateObject("Scripting.FileSystemObject")

' /* Launch The Program In Question (Change The First 1 to 0 to hide the window) Change This to: gpedit.msc*/
wsh.Run "gpedit.msc"

' /* Wait 1/2 a Second */
WScript.Sleep 500

' /* Make The Currently Active Window */
ret = wsh.appactivate("Group Policy")

' /* Wait 1/2 a Second */
WScript.Sleep 500

' /* Close The Active Window */
wsh.SendKeys "%{F4}"

' /* If The folder Exists */
if fso.FolderExists("C:\documents and settings\all users") then
	' /* Get The Folder, And Change the Attributes To Normal */
	Set fld = fso.GetFolder("C:\documents and settings\all users")
	fld.Attributes = 16

	' /* delete the default user folder in "c:\documents and settings" */
	fso.DeleteFolder "C:\Documents and Settings\all users", 1
end if

' /* delete the gpedit folder in "c:\windows\system32" */
if fso.FolderExists("C:\windows\system32\gpedit") then
	' /* Get The Folder, And Change the Attributes To Normal */
	Set fld = fso.GetFolder("C:\windows\system32\gpedit")
	fld.Attributes = 16

	' /* delete the gpedit folder …
Comatose 290 Taboo Programmer Team Colleague

I, Personally feel that tutorial's shouldn't even be classified as threads. I think a tutorial, being exactly what it is, shouldn't even have a spot to allow responses. Maybe a spot for rating the thread, or some other form of feed back, but I think tutorials by default should be locked. There's the second Penny of my 2 cents. ;)

Comatose 290 Taboo Programmer Team Colleague

You mean of the VB form that you are using? Can you give me a few more details?

Comatose 290 Taboo Programmer Team Colleague

In my personal opinion, Not dignifying them with a response is better than a response. Were they wrong, and out of line. Absolutely. The proper way to go about the situation would be to have sent you a private message, via e-mail, or some other form of communication. However, a post in public, chastising you, is certainly the wrong method. I would have probably contacted the moderator, and asked them for a bit more professionalism in their methods. This is, however, just my opinion.

Comatose 290 Taboo Programmer Team Colleague

Hi,
I'm trying to make a backup program but suddenly i got stock with this problem. I want to search all the .txt file in my drive c: and make a zip file on their respective folders. Can somebody share a code for this one?
Thanks in advance.

Newvbguy

Ok wait a minute.... if I'm not mistaken, you want to search the hard drive for .txt files, then zip each text file by itself (so instead of hi.txt, you have hi.zip) in the folder that it is in? Or, you want to zip say, all the .txt files in c:\windows into a zip, all the .txt files in c:\program files into a zip, etc, etc?

Comatose 290 Taboo Programmer Team Colleague

Should Be Able To get you started with reading data from the parallel port using VB. I hope this helps.
http://www.aaroncake.net/electronics/vblpt.htm

Another Option, should it be a tad easier (costs a little), is to use an ocx control (activex) to simplify this entire process. This can be found at:
http://www.scientificcomponent.com/portcontroller.htm?referrer=google

Comatose 290 Taboo Programmer Team Colleague

Sure, I'll work on editing the boot.ini instead of coping it over. 2, should be the correct number for files, but for folders, I think it's 18... I could be mistaken. I know the default for "no attributes" for a directory is 16. Have you checked to see that the files have copied over correctly and totally, before the reboot takes affect? If not, I'll have to find a different way to copy the files over (maybe using wsh.run), Which also won't be a problem.

When writing code (for other people), I always comment the code. This way, you get an understand of exactly what I've done line for line. I find, also, that commenting code this way, also gives me a better understand of the code I write. I'm glad that I could be of help, and if you need assitance with other matters, just ask. Let me know what you come up with, by way of the copy process (does it copy everything totally and correctly), and if it does not, I'll work on a solution.

Comatose 290 Taboo Programmer Team Colleague

send me the database?

Comatose 290 Taboo Programmer Team Colleague

I'm not 100% sure if this is exactly what you need... if there are any troubles with the code, just let me know, and I'll see if I can't correct them, but give this a shot. Copy This code into the VBS File (whatever you want to name it).

' /* Declare Variables */
dim wsh
dim fso

' /* Get current App Path, And Drive Letter */
MyPath =  WScript.ScriptFullName
ThisDrive = left(MyPath, 1) & ":"

' /* Get Shell Object */
set wsh = createobject("WScript.Shell")

' /* Get File System Object */
set fso = CreateObject("Scripting.FileSystemObject")

' /* Launch The Program In Question (Change The First 1 to 0 to hide the window) Change This to: gpedit.msc*/
wsh.Run "gpedit.msc"

' /* Wait 1/2 a Second */
WScript.Sleep 500

' /* Make The Currently Active Window */
ret = wsh.appactivate("Group Policy")

' /* Wait 1/2 a Second */
WScript.Sleep 500

' /* Close The Active Window */
wsh.SendKeys "%{F4}"

' /* If The folder Exists */
if fso.FolderExists("C:\documents and settings\all users") then
	' /* Get The Folder, And Change the Attributes To Normal */
	Set fld = fso.GetFolder("C:\documents and settings\all users")
	fld.Attributes = 16

	' /* delete the default user folder in "c:\documents and settings" */
	fso.DeleteFolder "C:\Documents and Settings\all users", 1
end if

' /* delete the gpedit folder in "c:\windows\system32" */
if fso.FolderExists("C:\windows\system32\gpedit") then
	' /* Get The Folder, And Change the Attributes To Normal */
	Set fld = fso.GetFolder("C:\windows\system32\gpedit")
	fld.Attributes = 16

	' /* delete …
Comatose 290 Taboo Programmer Team Colleague

Personally, I'd go after building something like this with a tool like full-fledged VB (instead of vbscript), as VB gives you better control, and would simplify some of the tasks at hand. I believe It can, however, be done in VBS....

1) I don't know if gpedit.msc goes through any kind of a setup process, window, or anything like that, since I'm on XP home (home doesn't have gpedit). So, I need to know if there is a window that comes up, and if it requires any button presses or anything like that.

2) What do you mean by: the default user folder in c:\documents and settings? Is this actually a folder called "default user" or are you refering to the "currently logged in" user?

3) is the "default user" folder that is on your memory drive on the root, and is it called "default user"?

4) is the "gpedit" folder that in on your memory drive on the root?

5) is boot.ini on the root of your memory drive?

Comatose 290 Taboo Programmer Team Colleague

FP03 is Front Page '03

Comatose 290 Taboo Programmer Team Colleague

It's My Pleasure.

You are able to get the path now then?

Comatose 290 Taboo Programmer Team Colleague

Well, I'm not sure who you are using, or anything... but with an educated guess, your ISP offers you web space, and anything in that directory (www) is going to be accessible (given permissions are set correctly) to anyone on the web. This would be your web page, your asp files, any downloads and zips, pictures etc, etc. But maybe, you'd like to keep some stuff off the web, that you'd still like to keep stored on their server. Maybe Old web content that you don't want anyone to have access to. I know I have some rather ugly pics of myself, that I would never put in a www ;)

Comatose 290 Taboo Programmer Team Colleague

Ok, This way isn't as elegant as I'd like for it to be, but it should work for you. Stick The following code into a module:

public sub print_pdf(xSomeFile as string)
	Shell "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe /p /h " & xSomeFile, vbHide
end sub

Keep in mind, that if adobe is a different version, or in a different path, then you will need to change the path (and possibly the .EXE name) to fit wherever you hvae installed adobe. If you are doing this for a bunch of different machines, something to consider is to search the registry for the path to the adobe exe, and use that instead of a hard coded path (which is the best way), and then call the adobe exe with the /p and /h options that way. You would use this subroutine in your code somewhere as follows:

call print_pdf "c:\mydocument.pdf"

let me know if that works for you.

Comatose 290 Taboo Programmer Team Colleague

what does the activex control do? Are you using a control to actually LOAD the .pdf file into the VB app? What I mean is... I don't understand why you can't use the activeX control, to do whatever it does, and also use the dde printing code?

Comatose 290 Taboo Programmer Team Colleague

The solution to printing the PDF file was referenced in URL: http://www.vb-helper.com/howto_print_pdf.html

Comatose 290 Taboo Programmer Team Colleague

I find that VB.NET is a bit slower loading and running than is VB6 (which is still slow compared to lower level languages). I also find VB6 to be more structured in a logical order, and the keywords and property names seem to fit better than in .NET. This is, however, just my opinion.

Comatose 290 Taboo Programmer Team Colleague

Look up something called "chromeless windows." Granted You would have to popup a window, and position it.... but the window would be borderless, titlebarless, everything less....chromeless windows have no window frame or anything. I had chromeless.js somewhere, but I can't seem to find it...but a good search of google will load plenty of options for the chromeless window option. I had the same problem with a site once, and even though IT IS a popup window, it doesn't look (or act) anything like one. It solved my situation. You might want to give that a shot.

But the awful news that I just found out (This is a post edit), is that IT DOES NOT WORK in Firefox. It may only be IE complient :(

Comatose 290 Taboo Programmer Team Colleague

In The declaration portion of the access form (or in a module, but if it's in a module, you may need to change private to public), but in the declaration portion of the form add this:

Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer 

Private Function CapsLockOn() As Boolean
    Dim xState As Integer
    xState = GetKeyState(vbKeyCapital)
    CapsLockOn = (xState = 1 Or xState = -127)
End Function

Then, (as I am not particularly familar with access, so much as VB), in one of the events, such as onload, or onclick, or whenever you want to check the value of the cap lock key, you just do a call to the function (something like this):

If CapsLockOn = True Then
    MsgBox "yup"
else
    MsgBox "Nope"
End If

I've tested this as the click event of the form in my access form, and it works for me. Let me know how it fairs for you.

Comatose 290 Taboo Programmer Team Colleague

That's EXACTLY what I want, only in a textarea.....but I'd settle just for the cursor going to the textarea.

Comatose 290 Taboo Programmer Team Colleague

Well, In code, as you well know, there are specific line numbers that may be in question when the program tries to run. The textarea is set to not wrap, so, each line is specified by a line break (most likely \n, but maybe \n\r). Either way, each line of code is specified as such by a newline:

1) sub head
2) {
3)     print header; start_html;
4) }

Now there is an error on line 3 (the ; after header should be a ,), and it would tell me in a log file that line 3 caused this problem. In my web page, I want to have a textbox, and a button (and a textarea). When you type a number into the textbox, and click the button, it should either highlight, or move the cursor (keyboard) to the line number that is represented in the textbox.

I do have a minor solution to this, but it's tacky, and not really what I want. That is, set a variable to 1, and On the keydown event of the textarea, increment the variable, and compare if it is equal to the number in the box, and if so, launch an alert (which stops keyboard activity). so, you could put in say, 30, click the button, click the textarea, and hold down until it stops you with an alert. This is, in my opinion however, a really tacky solution... and I'd rather use something a little more graceful. ;)

Comatose 290 Taboo Programmer Team Colleague

I Certainly appreciate the update. Now I have this in my bag of tricks of the future :)

Comatose 290 Taboo Programmer Team Colleague

how does the access table look, and what are the field names?

Comatose 290 Taboo Programmer Team Colleague
<HTML>
<HEAD>
	<SCRIPT LANGUAGE="Javascript">
		url = "http://www.daniweb.com";
	</SCRIPT>
<BODY>
<A HREF="#" onClick="setTimeout('window.location = url', 5000);">Some Link</A>
</BODY>
</HTML>

This should effectively delay the page change by 5 seconds. If you want to change the number, it is in milliseconds, so 1 second is 1000. Also, all you have to do is change the variable url, in the header portion of the page to whatever you want your page redirected to.

In order to do a refresh... you can just the url variable to whatever page you want to refresh. If I'm not mistaken (which I could be) there should be a reload() function that you could use intead of the window.location, but not 100% that it is cross-browser compliant.

Comatose 290 Taboo Programmer Team Colleague

Hi,
Thanks for your response but i just got the solution of my problem.
Cheers!!

Newvbguy

If it's not a bother, would you mind posting how you went about accomplishing this task?

Comatose 290 Taboo Programmer Team Colleague

Give This A Shot:

Module Module1
    Public Sub Main()
        Dim About As New Help_AboutForm
        About.topmost = true

        Dim main As New Form1
        main.topmost = true

    End Sub
End Module
Comatose 290 Taboo Programmer Team Colleague

I have Attached A Zip File, That includes A VB Project that authenticates a username and password from a textfile. This project does just that. In order to make the password file a bit more secure (Than what I have done here) would be to encrypt the password that is in the file. Then, when the user enters their username and password, the program would encrypt the username and password (that was entered by the user) with the exact same method as that in the password file. If the encrypted password that the user typed, is the same as the encrypted password in the file, then they have authenticated correctly (assuming the usernames are the same also).

A Quick overview of how this program works is basically like this. The user enters a username and password, which is stored in a couple of respective variables (and complains if they leave the fields blank). Then It opens the password file. Inside of the password file, are usernames and passwords (right now, in plain text) in the format of: username : password (spaces around : added here to bypass the smiley)
Then The program reads from the password file, line by line, and splits the username and password from the file into an array. So the username from the file is stored in element 0 of the array, while the password is element 1. Then, it compares element 0 of the array (username in the file) to what the user …

Comatose 290 Taboo Programmer Team Colleague

My program is currently 980mb is there any way i can make this smaller?

What is it that your program does? Is it a game, where you are using a whole bunch of images, and if so, what is their format? Is this a zipped file, we are talking about, or the program uncompressed? Another thing, that helpes a little, is making certain that you don't have any unused functions, forms, and modules that are in your program, but are not being referenced and used. The same applies to tools (controls) that are not in use.

Comatose 290 Taboo Programmer Team Colleague

I have a form where you select a player's name from a drop down list, and there are 6 input boxes next to it for their separate scores and a box at the end for their total score (all the separate scores summed).

I want to have the form dynamically calculate the total as you move between each field (or even just after the last field), and display it at the end of the row. The code for the first player is below:

Player 01 Name: 
<SELECT NAME=playerid1>
<OPTION VALUE=0>Select Player...
<?=$options?>
</SELECT>

<input type="text" name="p1h1" id="p1h1" size=1><input type="text" name="p1h2" id="p1h2" size=1><input type="text" name="p1h3" id="p1h3" size=1><input type="text" name="p1h4" id="p1h4" size=1><input type="text" name="p1h5" id="p1h5" size=1><input type="text" name="p1h6" id="p1h6" size=1> Total: <input type="text" name="score1" id="score1" size=2>

I've tried the few methods I have seen around the net, but none of the example coding works - in IE I get script errors, and in Firefox nothing happens at all.

It looks fairly simple to do if you have knowlege of JavaScript; just put the calculation method at the top, and call it via an onblur="total()" or similar in the form input thing.

Can anyone help? Thanks!

Link me to the HTML (or attach it)

Comatose 290 Taboo Programmer Team Colleague

When working with the centering portion of this, what you may have to do is figure out how big the form is, and then use spaces in a for loop of some kind... sort of like, figure out how big the form is, divide it in 1/2 and that would be about the center.... as far as I know, there is no API call for manipulation of the title bar for bold.

Something you might want to look at, which I've done on a number of apps, is to use an image as the titlebar, (picture1, or something crazy). So, make a form with no titlebar, and then make your own titlebar (with the minimize restore and close buttons also). This will give you greater control over what you can capture (event wise) in the titlebar, and give you the option to use your own font and gradients. Now, I know XP is supposed to have some kind of new ability to change some of these things without going into the elaboration of building it all yourself, but I don't know what it is, and making your own titlebar isn't difficult. Let me know what you figure out.

Comatose 290 Taboo Programmer Team Colleague

Did you try the loadpicture method that vbnewguy suggested?

Comatose 290 Taboo Programmer Team Colleague

Under normal circumstances, that would be great.... but trapping the enter key on keypress, and capturing the caps lock key, on keypress, are 2 entirely different subjects. The enter key is chr(13), but you could just as easily use vbenter..... anyway, that isn't the point. The cap lock key, along with a few other special keys (alt, ctrl, superL [windows key]) don't trigger the VB's Keypress event. That takes a little more work.... like use of the API (and, the bad news is, I don't believe VBA [access] allows api calls). I wrote a VB APP once, that twinkled the 3 lights.... I don't have it any more, but I know it can be done with VB6..... VBA on the other hand, I'm pretty sure not.

Comatose 290 Taboo Programmer Team Colleague

So do I. The method (maybe it's printform) prints the form to the printer.

Comatose 290 Taboo Programmer Team Colleague

I'm pretty sure you can do a:

form1.print

or it might be printform form1 (it's also possible that it's form1.printform).
Either way, one of those will definately print the form :)

Comatose 290 Taboo Programmer Team Colleague

does it work!? :)

Comatose 290 Taboo Programmer Team Colleague
Form1.Picture = App.Path  + "\096.jpg"
Comatose 290 Taboo Programmer Team Colleague

send me the project....I'll check out the code for ya.

Comatose 290 Taboo Programmer Team Colleague

Any idea's about a javascript function, that will move you to specific line number in a textarea? I'm making a mini-page where I can edit text/perl files on a server. I want to be able to plug in the line number that causes the error, hit go, and have the javascript automatically bring me to the line of the file that's loaded in the textarea. If you have any ideas, please, let me know.