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.

2201.

Solve : Portable Apps?

Answer»

I want to create portable applications in VB6 like other available portable applications on net.

There is any possibility to creating portable applications in VB6? It all depeneds on what you wanna make. Most things you code in languages and compile are portable in the fact that you have an exe and you can put it on your flash drive and load it normally on most 32/64 bit windows system.

If you need to touch the REGISTRY then it will obviously not be portable.

But yeah you probable do not need to do that for most applications you make (although i do not know what you are making).

By the in vb6 to make an exe you will need the enterprise edition its under file make exe
Thank you for the reply.


Quote

It all depends on what you wanna make.

I want to create CD autorun menu with the few options like to install the software which is presented on CD and run that software if already installed the system.


Quote
By the in vb6 to make an exe you will need the enterprise edition its under file make exe

I know and I have.


Quote
in the fact that you have an exe and you can put it on your flash drive and load it normally

The vb6 application (exe file) needs vb6 runtime files to run. For my above need that's not possible in vb6 even supply exe with runtime files.


Why I ask it in vb6. VB6 is very easier than other languages.

If you have any guide please reply me. Language is not problem. But it must be cross windows application.I was under the IMPRESSION that the vb runtime was distributed with windows since windows 2000.Quote from: IamError on January 25, 2009, 06:29:21 AM
I was under the impression that the vb runtime was distributed with windows since windows 2000.

That is correct. However, service pack levels can be an issue. Google is your friend!


Make EXE is in the Visual Basic 6 Professional and Enterprise editions, not just enterprise. (Trust me, I collect these things, I have every version back to version 1!)

Even pushing the MSVBVM60.dll service pack level issue aside, there is still the likelyhood that additional References or Controls will be needed for the application; if this is the case, it will be necessary to register them either before running the app or before using Controls.Add() or CreateObject() to create instances of the referenced objects.Thanks to ALL.

@BC_Programmer:

Quote
if this is the case, it will be necessary to register them either before running the app ...

Can I register them during EXE loading?

That means self registering.
No.

Although if you use Late binding, Controls.Add and CreateObject(), you can manually REGSVR32 the required libraries and the create the objects.Quote
you can manually REGSVR32 the required libraries and the create the objects.

Manual registration is too waste. Because user need to know about it and it may irritate the user.


You may saw the autorun menu on few of Games CD with options like Install, Run, Exit etc... while inserting CD.

That menu appeared with out any interaction with the user.

We can create like that menu in Flash but not well in coding and it have some limitations.

Thanks.I MEANT manually program it in. IE: shell..OK. I Will try this. Are you tried it before?Quote from: CBSk on January 27, 2009, 09:37:45 PM
OK. I Will try this. Are you tried it before?

Sort of- for a script language interpreter I wrote. it uses the language DLL and a few other components that need to be registered, so it uses late binding and if an error occurs with the createobject() call it will check for the DLL files in it's folder and register them, then try again. I don't use REGSVR32 but rather some calls to Typelib information function to register the type libraries but it's the same EFFECT.
2202.

Solve : need suggestions?

Answer»

hi, i'm having a bit of a problem
I started in a new job and i have no more time to spend programming in my site... i want to keep it but i don't have any time to program new features... I don't know what to do, a friend RECOMMENDED this site, he said they do JOOMLA programming but i've never used this kind of services .
What do you recommend?
should i GIVE it a try?
Thank you

Victoria

[link de-linked]Dotrey?Quote from: CARBON Dudeoxide on January 23, 2009, 08:15:54 AM

Dotrey?

Whats that?If Vic62 ever returns, he will understand.
2203.

Solve : How caan I write a real program with NO .NET junk??

Answer»

How can I write a real program with NO .NET junk?
I don't like .NET.
I don't understand .NET.
It does too long install.
It annoys me.
And I just can not use a program that VIOLATES simple English grammar with is funky name! Dot net?
They should have called it "Dognet" and maybe ... Sure. Write a program in assembly.What language do you actually want to program in? If you use vb, just program in vb6. Also, can you define the ".net junk" you keep talking about?Quote

Sure. Write a program in assembly.

OK. I am WILLING. But I need an API list for Windows.
I have never done GUI in assembly.
Was there Once Upon a Time a Visual ASM

The only API I know is the standard console stuff.
Do I have to buy an SDK THING to program in ASM?

Is there a web site that gives info about doing a simple
Windows program in ASM? Quote
Do I have to buy an SDK thing to program in ASM

No

Quote
Is there a web site that gives info about doing a simple
Windows program in ASM?

Here's a simple tutorial. With most operating systems you have to download the ASM interpreter(or whatever you call it).

Quote
I have never done GUI in assembly.

If you aiming at GUI's, don't do assembly. AutoIt is easy. It's good for writing PROGRAMS.. It's
practically as easy as batch files. However like ASM, you have to download a special interpreter.
However ASM, is more POWERFUL that AutoIt.

Quote
Was there Once Upon a Time a Visual ASM


Never was and never will be.


Hope that helped!
2204.

Solve : Another GDI+ Question?

Answer»

In Visual Basic .net, (using vs 2003 but I have 2008 ASWELL, if I absolutely *have* to use it, I dislike how they removed the "windows form designer generated code" section, but I digress) when you go to draw something the coordinates LOOK like this:


Is there any way to easily MAKE it so it was more like this:?


In the past I have used equations which change the co-ordinates accordingly - I'm just wondering if there is another way.Or at any rate, some kind of generic equation which can go into any form - I'm working on one at the moment, but it doesn't QUITE work...I know something like
Code: [SELECT]pointA.X += 200
pointA.Y += 200
pointB.X += 200
pointB.Y += 200does the trick, but its not quite what I'm looking for...

2205.

Solve : AutoItv3: How to store random numbers in a variable.?

Answer»

In AutoItv3, there is a command random which SPITS out a random NUMBER. How would you STORE the random number it GIVES in a VARIABLE.

2206.

Solve : Using .bat to copy files to ext HD, dest. folder disappears?

Answer»

Trying to use a simple batch to copy the c:\ to an external harddrive.

Batch is :

XCOPY "c:\" "E:\Test Backup" /D /E /C /R /I /K /Y

The problem is everytime I start the batch it appears to be copying (DOS window OPENS with files scrolling) but the destination folder disappears after about 10 seconds. Theres plenty of space on the external HD. When I try to create a new folder with the same name I get the "file with this name already exists. specify new name." I've checked the "show hidden files" box and that doesnt show it either. Not sure if the batch file is the problem or if copying all of C is just too much for it. Not very experienced with .bat so that could be it. Any help would be appreciated.

DanQuote from: dbrace55 on MARCH 25, 2009, 07:44:18 AM

Trying to use a simple batch to copy the c:\ to an external harddrive.

Batch is :

XCOPY "c:\" "E:\Test Backup" /D /E /C /R /I /K /Y

Dan

What is the '/d' parameter for?

/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.When using commands, I'm fairly sure switches have to be in the order displayed in Command /?

Quote
Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
[/EXCLUDE:file1[+file2][+file3]...]

source Specifies the file(s) to copy.
destination Specifies the location and/or name of new files.
/A Copies only files with the archive attribute set,
doesn't change the attribute.
/M Copies only files with the archive attribute set,
turns off the archive attribute.
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files. When any of the
strings match any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories except EMPTY ones.
/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.
/V Verifies each new file.
/W Prompts you to press a key before copying.
/C Continues copying even if errors occur.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.
/Q Does not display file names while copying.
/F Displays full source and destination file names while copying.
/L Displays files that would be copied.
/G Allows the copying of encrypted files to destination that does
not support encryption.
/H Copies hidden and system files also.
/R Overwrites read-only files.
/T Creates directory structure, but does not copy files. Does not
include empty directories or subdirectories. /T /E includes
empty directories and subdirectories.
/U Copies only files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

Oh and I didn't manually write that out, I just found that you can redirect help to a file! Xcopy /? > file.txtQuote from: Helpmeh on April 07, 2009, 05:11:19 PM
When using commands, I'm fairly sure switches have to be in the order displayed in Command /?

Not always, and not with xcopy. One gramme of experiment is worth SEVERAL tonnes of guesswork, as Professor Metric might have said.

Code: [Select]xcopy /s /l /d:04-01-2009 c:\batch d:\batch
xcopy c:\batch d:\batch /s /l /d:04/01/2009
xcopy c:\batch d:\batch /l /s /d:04/01-2009
xcopy /d:04-01-2009 c:\batch /s /l d:\batch
all work just the same

source and destination have to be in that order but they can be anywhere and the switches can be in any order, and the date separator can be - or / or a mixture ie 04-01/2009 works. The /L switch is very handy when experimenting with xcopy.


Quote from: dbrace55 on March 25, 2009, 07:44:18 AM
Trying to use a simple batch to copy the c:\ to an external harddrive.


If you think that this is going to back up your system you may be in for a nasty shock if you ever need to restore it...

Quote
If you think that this is going to back up your system you may be in for a nasty shock if you ever need to restore it...

Unless your are a network administrator, there is little reason to use DOS for file backup.
The best, simple, backup method inside of Windows NT,2000,2003, XP is to just use the backup utility. The problem is that many people just do not take the time to learn how it works. Once you get it, you will never go back doing a batch to backup large file sets. It allows multiple backups, compression, PASSWORD protection, overwrite by date, save if modified, and so on. You can restore a single file, a folder, or part of a folder, several folders, and so one.
Bit of coarse, you could do it all in batch. Like using a pair of scissors instead of a lawn mower to cut the grass in the front yard.
Quote from: Geek-9pm on April 09, 2009, 01:51:00 PM
Unless your are a network administrator, there is little reason to use DOS for file backup.

I meant if he thought he was doing the equivalent of Ghosting his C: drive to back up his OS.Quote
...thought he was doing the equivalent of Ghosting his C: drive ...
Right. I missed that. Image is easier.
Here is a video he should see.
Runtime Software
DriveImage XML tutorial

Even if you do not want their free product, you want to see this video.
2207.

Solve : Script Which Will Act As An Interactive Front End To An Emailer?

Answer»

I want to write a script that
Code: [Select]-ASK the user which files they want to sent (files not needed to be in the same directore
-tar all the files together
-Gzip the tarfile
-Uuencode the gsipped file (so more email programs can use it)
-ask user who to send email to, possibly more than one person
-I want it to be clear and easy to use and display what it is doing while an action is taken place.

I have no clue where to BEGIN. I think perl would be the best option, but I am not sure, how would I make this able to run with am email program and I am unaware how to tar and gzip files or Uuencode the gsipped files.

Can SOMEONE help me get my feet wet so I can make this program? I have no clue where to begin.
you have some hints hereWhere to start?
Why not start with a HTML document.
If this is a program for general use, and it email is what it is about, then it would make sense to does do in in a document based on HTML. Not that I am a fan of HTML. No, I mean you would have a portable application that can be used on the web or an almost any PC.
Some of the new web design tools will do the actual code for you. You just choose a deign an style.
Or, just find a free program somebody has already made.

This script will be used in UNIXSorry, I was thinking you just wanted to automate e-mail on you local machine in Windows.

Is this for a Unix server?
Does the machine already work as a SMIP serverver?
In Fedora, TRY a program called 'Nail' which I know nothing about.
You said where to start?
Well, the Ubuntu forum is a go starting point.
Here is a article about doing it in BASH.

How to send email using bash


You will have to read through it an find the problems others have had. This is at least a go start, SEEING what others try.

2208.

Solve : BIOS and Windows load once in a while!!!!!?

Answer»

I'm a very knowledgeable person of building computer and doing everything myself all though I'm having some problems.. I stayed up till 12:30 one night and turned off my computer and WENT to bed.. when i woke up i tried to turn on computer and the computer started up but the BIOS and Windows did not load... I took out hardware and put it back together, and when i started it it worked but only five minutes then it crashes... it works after an hour of leaving the computer alone... It finally told me to repair windows all though i cant get my CD/DVD ROM/Burner working when i connect it with just a power cable it works but when i plug in the DVD ROM Data cable it does'nt seem to accept the power.. any ideas?
Specs
AMD Athlon 64 X2 2.6GHz 2x512kb
I have 3 hardrives and they all do the same thing, i have a 250gig 7200 rpm hardrive, a 150 gig 10000 rpms, and a 80gig 7200 rpm
2x EVGA NVIDIA Geforce 8800GTS Graphics card
2x G.SKILL 2GB (2 x 1GB) 240-Pin DDR2 SDRAM DDR2
Sony CD/DVD ROM/Burner
I it matter i have 3 monitors HOOKED up to computerPerhaps try posting in the Windows sectionoh thx i guess i willQuote

does seem to accept the power.. any ideas?

Extensive empirical research over many has show
there is credible evidence for this factoid:

Usable hardware...is.. ah.. unstable!


English translation: BAD DVD drive

Italian translation is not as polite:
Se LA Sony è falsa.

ooops i meant doesn't accept power
2209.

Solve : Java Applications?

Answer»

I heard that its possible to write c code and get programs to run in windows. I only KNOW some java but wondered if you could do the same thing. I have made APPLETS and regualar java files and what ever the thrid format is.yes, you can write windows programs in C.

it's not for the faint of heart... in fact it's not a path taken by SANE programmers either.


http://www.relisoft.com/win32/generic.html


EDIT: never MIND, thats C++...

EDIT: ahh, GOOD ol' MSDN:

http://msdn.microsoft.com/en-us/library/aa383668(VS.85).aspxQuote from: squall_01 on April 08, 2009, 01:36:58 PM

I only know some java but wondered if you could do the same thing. I have made applets and regualar java files and what ever the thrid format is.
so- you want to create a windows program in java? where does C come in?
2210.

Solve : Visual Basic 2008: Writing and Reading?

Answer»

Hey guys, I know you're all really helpfull in the MS-DOS section, let's just hope that's the same here.

What I'm trying to do is:

1. Display the entire contents of a file (could be over 100 lines) and refresh every second or so
2. Append text from a textbox to the end of that file.

I just got Visual Basic 2008 because my friend says it's really easy, but I'm not that good. So far, I have a regular textbox (textbox1), which is where I would append the text, a read-only, multi-line textbox (textbox2), which is what I want to display the file contents and a button (button1) which would append textbox1.text to my file.


Is this even possible? If so, could you SHOW me how to do it?I'm not quite sure I understand want you want. From I gather, you want to read in from a text file every second. Then, any text that appears in textbox1, would be ADDED to the end of the text file, right? Are you hard coding the name of the text file or will you select it from a dialog window? How do you want the text in textbox1 to be added to the file, automatically or with a button? This is certainly possible. You'll just need to use a timer that is set to 1 second.Quote from: lordvader781 on April 07, 2009, 02:38:36 PM

I'm not quite sure I understand want you want. From I gather, you want to read in from a text file every second. Then, any text that appears in textbox1, would be added to the end of the text file, right? Are you hard coding the name of the text file or will you select it from a dialog window? How do you want the text in textbox1 to be added to the file, automatically or with a button? This is certainly possible. You'll just need to use a timer that is set to 1 second.

You're right about what I want to do, and the file will be hard coded into the code (imtp.txt). And as I said before, button1 will send textbox1.text to the file.

The only code that I've actually managed to do is change the text of a label on a button click...so this is a bit advanced.I'd post a VB6 equivalent but it would probably be a Pain to convert to .NET; I don't think .NET has the VB6 file access functions/statements.Quote from: BC_Programmer on April 07, 2009, 04:56:18 PM
I'd post a VB6 equivalent but it would probably be a Pain to convert to .NET; I don't think .NET has the VB6 file access functions/statements.

I'm a bit confused. If I make the program into a .exe in VB2008, will someone need .NET to run it? I don't think the people who will be using this have it...yes, they will need the .NET framework installed to run any applications created in Visual Basic .NET, C# or Managed C++.OK...that is a major setback...


Is there any way that they WON'T have to do that in VB2008?
If no, is there any way I can make it WITHOUT them downloading .NET? They can't get it...as deepfreeze will just restore it.well, I don't think it's possible- since the forms, buttons, etc are all stored in the .NET framework winforms library. IN fact- the entire program is just a .NET component (assembly) and so needs the .NET loader, mscoree.dll to be present.

now if you can get a HOLD of a COPY of an earlier version of Visual Basic, the runtimes for those won't be an issue- they are included in Windows 98SE, windows XP and windows Vista.

Unfortunately although there is a "Learning edition" of VB6 it doesn't allow the compiling of executables




Quote from: BC_Programmer on April 07, 2009, 05:52:20 PM
well, I don't think it's possible- since the forms, buttons, etc are all stored in the .NET framework winforms library. IN fact- the entire program is just a .NET component (assembly) and so needs the .NET loader, mscoree.dll to be present.

now if you can get a hold of a copy of an earlier version of Visual Basic, the runtimes for those won't be an issue- they are included in Windows 98SE, windows XP and windows Vista.

Unfortunately although there is a "Learning edition" of VB6 it doesn't allow the compiling of executables






Grr...And it's against the rules for you to provide me with VB6...

I have WinXPsp2...(for some reason I can't update to SP3)...
2211.

Solve : How to draw Isometric Grid Visual Basic .Net?

Answer»

This isn't exactly a question, more of a statement

On other websites, which i'm not a USER on, such as experts-exchange (i think? Or other ones anyway), people write up how to do things so others don't have to ask, and I don't know if anyone will ask this, but incase they do heres some visual basic.net code (vs 2003), a class, which makes an ISOMETRIC grid using GDI+ when provided with four corners:

Code: [Select]Public Class IsometricBase 'written by Hammond Pearce
'this class creats a set of points to make an isometric grid like so: (ASCII ART FOLLOWS - MONOSPACE FONT REQUIRED)
' 3________C__________4
' / /
' / /
' B/ /D
' / /
' /__________________ /
' 1 A 2

Private sideApoints As Point() 'all the points along side A
Private sideBpoints As Point() 'all the points along side B
Private sideCpoints As Point() 'all the points along side C
Private sideDpoints As Point() 'all the points along side D
Private lastgridlines As Integer 'last gridlines used in calculatepoints, used in draw_all_points
Private Stored_Corners As Point() 'last corners used in calculatepoints, used in draw_all_points
Public ReadOnly Property SideA_Points() As Point()
Get
Return sideApoints
End Get
End Property
Public ReadOnly Property sideB_points() As Point()
Get
Return sideBpoints
End Get
End Property
Public ReadOnly Property sideC_points() As Point()
Get
Return sideCpoints
End Get
End Property
Public ReadOnly Property sideD_points() As Point()
Get
Return sideDpoints
End Get
End Property

Public Sub Calculatepoints(ByVal Corner1 As Point, ByVal Corner2 As Point, ByVal Corner3 As Point, ByVal Corner4 As Point, ByVal NumberOfGridlines As Integer)
'set up all variables
Stored_Corners = New Point(4) {New Point(0, 0), Corner1, Corner2, Corner3, Corner4} 'store the last points with an offset (the newpoint) so that its more userfriendly for me! :D
lastgridlines = NumberOfGridlines 'store the number of gridlines
Dim count As Integer 'used to put data in correct pocket in array
sideApoints = New Point(NumberOfGridlines) {} 'reset arrays ready to store
sideBpoints = New Point(NumberOfGridlines) {}
sideCpoints = New Point(NumberOfGridlines) {}
sideDpoints = New Point(NumberOfGridlines) {}
Dim temppoint As New Point 'used in do... loop as a temporary point to store values in

'side A
'reset common variables
count = 0
Do Until temppoint.X = Corner2.X And temppoint.Y = Corner2.Y 'do until the temppoint = the point we are working to
count += 1 'increment pocket
If count > NumberOfGridlines Then Exit Do
temppoint.X = Corner1.X - (Corner1.X - Corner2.X) / NumberOfGridlines * count 'these two instructions calculate the points between corner1 and corner3
temppoint.Y = Corner1.Y - (Corner1.Y - Corner2.Y) / NumberOfGridlines * count
sideApoints(count) = temppoint 'store the temppoint as a real point
Loop
'side C
count = 0
Do Until temppoint.X = Corner4.X And temppoint.Y = Corner4.Y 'do until the temppoint = the point we are working to
count += 1 'increment pocket
If count > NumberOfGridlines Then Exit Do
temppoint.X = Corner3.X - (Corner3.X - Corner4.X) / NumberOfGridlines * count 'these two instructions calculate the points between corner1 and corner3
temppoint.Y = Corner3.Y - (Corner3.Y - Corner4.Y) / NumberOfGridlines * count
sideCpoints(count) = temppoint 'store the temppoint as a real point
Loop
'sideB
count = 0
Do Until temppoint.X = Corner3.X And temppoint.Y = Corner3.Y 'do until the temppoint = the point we are working to
count += 1 'increment pocket
If count > NumberOfGridlines Then Exit Do
temppoint.X = Corner1.X + (Corner3.X - Corner1.X) / NumberOfGridlines * count 'these two instructions calculate the points between corner1 and corner3
temppoint.Y = Corner1.Y + (Corner3.Y - Corner1.Y) / NumberOfGridlines * count
sideBpoints(count) = temppoint 'store the temppoint as a real point
Loop
'sideD
count = 0
Do Until temppoint.X = Corner4.X And temppoint.Y = Corner4.Y
count += 1
If count > NumberOfGridlines Then Exit Do
temppoint.X = Corner2.X + (Corner4.X - Corner2.X) / NumberOfGridlines * count
temppoint.Y = Corner2.Y + (Corner4.Y - Corner2.Y) / NumberOfGridlines * count
sideDpoints(count) = temppoint
Loop
End Sub
Public Sub Draw_All_Points(ByVal graphicsobject As Graphics, ByVal P As PEN)
'this subroutine draws the isometric grid according to the sidepoints and the stored corners, using the lastgridlines variable to control the arrays
With graphicsobject
.DrawLine(P, Stored_Corners(1), Stored_Corners(2)) 'draw the SIDES
.DrawLine(P, Stored_Corners(1), Stored_Corners(3))
.DrawLine(P, Stored_Corners(2), Stored_Corners(4))
.DrawLine(P, Stored_Corners(4), Stored_Corners(3))
End With
Dim i As Integer
For i = 0 To lastgridlines
graphicsobject.DrawLine(P, SideA_Points(i), sideC_points(i)) 'draw the gridlines
Next
For i = 0 To lastgridlines
graphicsobject.DrawLine(P, sideB_points(i), sideD_points(i))
Next
End Sub

End Class
To use it you need to feed it four corners and the number of gridlines you want, also, if you want it to draw it for you, provide it with a graphics object and a pen to do it with. An example of this is here:
Code: [Select]Dim scr_graphics As Graphics = Me.CreateGraphics
Dim p As New Pen(Color.Green)
Dim corner1 As New Point(0, 200)
Dim corner2 As New Point(400, 400)
Dim corner3 As New Point(400, 0)
Dim corner4 As New Point(800, 200)
Dim myIB As New IsometricBase
Dim mygridlines As Integer = 10
myIB.Calculatepoints(corner1, corner2, corner3, corner4, mygridlines)
myIB.Draw_All_Points(scr_graphics, p)
Which results in:

All comments welcome! (Especially if they are methods of improvement)
Thanks,
Bones92Do your points support a Z axis value?

I had a similar transposition on my TI-83 calc- I called the program ThreeD, and it graphed 3d functions.

Not SURE if you'd have any use for it- but I used a fairly simple algorithm to convert X,Y and Z coordinates to X,Y coordinates that could be drawn:


DrawX = (X/2)+(Y/3)
DrawY = (Y/3)+(Z/2)

I imagine it would go into your code as a new procedure of some sort, for converting the isometric grid coordinates into a canvas location that you can draw to.
Funnily enough I did that last night afterwards, but slightly differently - you use an X and Y and Z from the grid the program draws itselfSince my above post, and as that was version 1.0, I am now up to version 4.2, which is capable of such drawings like the following:




I'll post code on request. I'm now working on layering, so I can have moving objects.Nice work!Hello,

I would like to know if anyone can help with this sample "Make a drawing application in VB .NET" (http://www.vb-helper.com/howto_net_drawing_framework.html).

I really loved the sample project and is helping me very much, but im stuck on a need i have that is moving the objects created.

In what way should i work so that after selecting an object with the mouse i could move it arround until it stops in a position.!!!!

I would be very thankfull if you could help me with this.

best regards,


Bruno Coelho
Quote from: jbscoelho on January 26, 2009, 01:19:29 PM

Hello,
Jbscoelho, please start your own topic.
Also, dont post your email, we dont work through email, and posting your email publicly on any forum can result in SPAM.
2212.

Solve : Keyboard input problem using Ncurses in C?

Answer»

Hey there. It's been a while since I've been around here.

I've run into a problem as I'm writing some simple code (mainly just to solve this problem) and I can't FIGURE out how to get around it.

Basically, when I want to take keyboard input, I could use keypad() but that causes a full 1000ms delay when the user presses the escape key.

This is because MANY keys ARE the escape key followed by other characters. (I'm talking non-ASCII, here; like arrow keys, function keys, etc.).

However, if I turn keypad() off, I can't figure out how to capture escape without having to hit it twice. All other keys work fine with the code I've written, it just hangs on Escape.

I understand WHY based on my code, I just don't know how to fix it.

Can anyone offer any solutions to the one second pause when using keypad() or a more successful way to manually capture raw keyboard input?

Here's my code:

Code: [Select]/*
* Author
* Venue
* Created: 00:00 Monday January 01, 2000
*
* Program description entered here
*
*/

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <ncurses.h>

#define UP_ARROW 65
#define LEFT_ARROW 68
#define DOWN_ARROW 66
#define RIGHT_ARROW 67


/*
* Type Declarations
*/

/*
* Global Variables
*/

int cheat;

/*
* Prototypes & Structs
*/

void titles(WINDOW *one, WINDOW *two);
int main_menu(WINDOW *menu_win, int key_press, int selector);
int inchk(WINDOW *WIN);
int chtchk(int key_press);

/*
* int main(void):
*
* main() description
*
*/
int main(void)
{
int select, ch;
WINDOW *std_win;
WINDOW *extra_win;

initscr();
raw();
noecho();
cbreak();

if(has_colors() == FALSE)
{ endwin();
printf("Your terminal does not SUPPORT color\n");
exit(1);
}

start_color();
assume_default_colors(COLOR_WHITE, COLOR_BLACK);
init_pair(1, COLOR_BLACK, COLOR_CYAN);
init_pair(2, COLOR_BLACK, COLOR_YELLOW);

std_win = newwin(50,19,0,0);
extra_win = newwin(50,100,0,19);

wbkgd(std_win, COLOR_PAIR(1));
wbkgd(extra_win, COLOR_PAIR(2));

titles(std_win, extra_win);

wrefresh(std_win);
wrefresh(extra_win);

while (1 == 1)
{
do
{
select = main_menu(std_win, ch, select);
wrefresh(std_win);
ch = inchk(std_win);
if (ch == -1)
{
endwin();
exit(0);
}
}
while (ch != 10);
mvwprintw(extra_win, 5, 1, "You chose option %d. Press escape to quit or choose another.", select + 1);
wrefresh(extra_win);
}
endwin();

return 0;
}/* int main(void) */

int main_menu(WINDOW *menu_win, int key_press, int selector)
{
int selection, startx, starty, temp;


startx = COLS / 20;
starty = LINES / 10;

if (startx > 3)
{
startx = 3;
}
if (starty > 3)
{
starty = 3;
}

selection = selector;

if (key_press == UP_ARROW || key_press == LEFT_ARROW)
{
--selection;
if (selection < 0)
{
selection = 5;
}
}
else if (key_press == DOWN_ARROW || key_press == RIGHT_ARROW)
{
++selection;
if (selection > 5)
{
selection = 0;
}
}

mvwprintw(menu_win, 1, 1, "Main Menu");
mvwprintw(menu_win, 1 + starty, startx, " Option 1");
mvwprintw(menu_win, 2 + starty, startx, " Option 2");
mvwprintw(menu_win, 3 + starty, startx, " Option 3");
mvwprintw(menu_win, 4 + starty, startx, " Option 4");
mvwprintw(menu_win, 5 + starty, startx, " Option 5");
mvwprintw(menu_win, 6 + starty, startx, " Option 6");

wattron(menu_win, A_REVERSE);
mvwprintw(menu_win, (selection + 1) + starty, startx, ">Option %d", selection + 1);
wattroff(menu_win, A_REVERSE);

return selection;
}

/*
* int titles(void):
*
* titles() description
*
*/
void titles(WINDOW *one, WINDOW *two)
{
mvwprintw(one, 1, 1, "Main Menu");
mvwprintw(two, 1, 1, "Game window?");
}/* int titles(void) */

/*
* int inchk(void):
*
* inchk() description
*
*/
int inchk(WINDOW *win)
{
char input;
input = wgetch(win);
if (input == '\033')
{
input = wgetch(win);
if (input == 27)
{
return -1;
}
}
else
{
return (int)input;
}

}/* int inchk(void) */
Any help would be appreciated. The INTERNET has NOT been beginner-friendly in my many C-related searches.

Also, I don't know if this is OS related or not, so I'm on a Unix operating system. I think it's Redhat. I'm running my software over an SSH connection to a university server, so I haven't delved very far into into it.

Thanks,
-rock

2213.

Solve : Javascript gradient background?

Answer»

Is there any way I can make a background with javascript that would look LIKE this:

I've made this with photoshop but when I want to add it to my site, it doesn't give the effect I want.
I would like to have that effect over the complete site, not repeated.

Is there anyone who knows how to do that?
Cause I can't wright java.

Thanks in advance

Jonas No need to double post..... I wasn't suppost to be a double post, I just hoped to find some guys over here who could wright javascript.
But if I'm double posting, feel FREE to remove it

I've found this here
Code: [Select]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="content-language" content="en" />
<title>Gradient Background</title>

<style type="text/css">
body {
padding: 0px;
margin: 20px;
background-color: #00CCFF;
}

#fadeBandsV {
position: absolute;
left: 0px;
TOP: 0px;
width: 100%;
height: 80px;
z-index: 1;
}

#fadeBandsH {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
z-index: 1;
}

#fadeBandsV div {
overflow: hidden;
position: absolute;
width: 100%;
}

#fadeBandsH div {
overflow: hidden;
position: absolute;
height: 200px;
}

#pageContent {
position: relative;
z-index: 2;
}
</style>

<script type="text/javascript">
<!--

// do not call this function directly - use createGradientV or createGradientH instead
function createGradient(direction, args) {
var bandSets = args.length / 4;
var startPos = 0;

for (var bandSetLoop=0; bandSetLoop<bandSets; bandSetLoop++) {
fadeFromColour = args[bandSetLoop * 4];
fadeToColour = args[bandSetLoop * 4 + 1];
bandSize = args[bandSetLoop * 4 + 2];
fadeSteps = args[bandSetLoop * 4 + 3];

// calculate stepped colour values for each band
var colourSteps = [fadeFromColour.concat()]; // ensure first colour is the start colour
for (var bandLoop=1; bandLoop<fadeSteps; bandLoop++) {
colourSteps[bandLoop] = [];
for (var rgbLoop=0; rgbLoop<3; rgbLoop++) {
colourSteps[bandLoop][rgbLoop] =
Math.round(colourSteps[bandLoop-1][rgbLoop] + ((fadeToColour[rgbLoop] - colourSteps[bandLoop-1][rgbLoop]) / (fadeSteps - bandLoop)));
}
}

// now draw each band
if (direction == 'V') {
for (var bandLoop=0; bandLoop<fadeSteps; bandLoop++) {
document.getElementById('fadeBandsV').appendChild(aDiv = document.createElement('div'));
aDiv.style.height = bandSize + 'px';
aDiv.style.top = startPos + (bandSize * bandLoop) + 'px';
aDiv.style.backgroundColor = 'rgb(' + colourSteps[bandLoop][0] + ',' + colourSteps[bandLoop][1] + ',' + colourSteps[bandLoop][2] + ')';
}
} else {
for (var bandLoop=0; bandLoop<fadeSteps; bandLoop++) {
document.getElementById('fadeBandsH').appendChild(aDiv = document.createElement('div'));
aDiv.style.width = bandSize + 'px';
aDiv.style.left = startPos + (bandSize * bandLoop) + 'px';
aDiv.style.backgroundColor = 'rgb(' + colourSteps[bandLoop][0] + ',' + colourSteps[bandLoop][1] + ',' + colourSteps[bandLoop][2] + ')';
}
}
startPos += fadeSteps * bandSize;
}
}

// createGradientV - creates a vertical gradient (North to South)
// Parameters: createGradientV takes a single set, or multiple sets of, 4 arguments:
// argument 1: fadeFromColour = an array of R,G,B colours to fade from (for example, [0, 0, 255] == #0000FF)
// argument 2: fadeToColour = an array of R,G,B colours to fade to (for example, [0, 204, 255] == #00CCFF)
// argument 3: bandHeight = height of each colour band
// argument 4: fadeSteps = number of colour bands used for the gradient (should be at least 2)
function createGradientV() {
if (arguments.length < 1 || arguments.length % 4 != 0) {
alert('Incorrect usage. Number of parameters must be a multiple of 4!');
return;
}
createGradient('V', arguments);
}

// createGradientH - creates a horizontal gradient (West to East)
// Parameters: createGradientH takes a single set, or multiple sets of, 4 arguments:
// argument 1: fadeFromColour = an array of R,G,B colours to fade from (for example, [0, 0, 255] == #0000FF)
// argument 2: fadeToColour = an array of R,G,B colours to fade to (for example, [0, 204, 255] == #00CCFF)
// argument 3: bandHeight = height of each colour band
// argument 4: fadeSteps = number of colour bands used for the gradient (should be at least 2)
function createGradientH() {
if (arguments.length < 1 || arguments.length % 4 != 0) {
alert('Incorrect usage. Number of parameters must be a multiple of 4!');
return;
}
createGradient('H', arguments);
}

function drawGradient() {
createGradientV([255, 0, 0], [255, 255, 0], 3, 50, [255, 255, 0], [0, 0, 255], 3, 50, [0, 0, 255], [0, 204, 255], 3, 50);
createGradientH([255, 0, 0], [255, 255, 255], 3, 50, [255, 255, 255], [0, 0, 255], 3, 50);
}

//-->
</script>
</head>

<body ONLOAD="drawGradient();">
<div id="fadeBandsV"></div>
<div id="fadeBandsH"></div>
<div id="pageContent">
<h1>A test heading</h1>
</div>
</body>
</html>
But I can't seem to find witch part I need to use and stuff, normally I'm pretty good in studying a prog language and use the parts I want and tweak them but this is a bit to hard for me.
Anyone who can help me?

Jonas Can you edit your last post there PLEASE..... oh srry, didn't notice it
Is it good like that?
I'm afraid it will be harder to read if I add more enters

Jonas

2214.

Solve : VB script help needed?

Answer»

Hi all, sorry if this is something simple, but...

I am TRYING to modify a VB script and change the line where it creates a log file. I want to add to the end of the name some sort of date/time stamp. Example: outputlog.txt would become outputlog.04032009.txt -or- outputlog.09111.txt the last one is YR/Julian day.

Any help is appreciated, thanks in advance.Files already have time stamps, so why do you need this?
Do you want just the date? CREATION date? Modify Date?
What does 09111 mean? In that Jan 11, 2009 ?
Do you have a BIT of the VB script that opens the log file?

You might be able to use:
Code: [Select]logfilename = "outputlog." & Replace( CStr( Date ), "/", "" ) & ".txt"NOTE: Replace "/" with your date separator character. Quote from: Geek-9pm on April 03, 2009, 03:21:19 PM

What does 09111 mean? In that Jan 11, 2009 ?

Quote
09111.txt the last one is YR/Julian day.

I'm a bit confused here. The Julian date (JD) is the interval of time in days and fractions of a day, since January 1, 4713 BC. The Julian date for CE 2009 April 4 00:00:00.0 UT is JD 2454925.50000

Julian date is sometimes used as a synonym for day of year, but this is not correct usage. Day of year ranges from 1 to 365 (366 for leap years). Today's day of year (4th April 2009) is 94.

So where did the 09111 come from?

Here is some date & time stamp vbs code

Code: [Select]
Dim dd,mm,yy,YYYY,DateStamp,FileName,DayOfYear,DoYstamp

dd=Day(Date)
mm=Month(Date)
yyyy=Year(Date)
yy=Mid(yyyy,3,2)
DayOfYear=(DatePart("y",Date))

If dd<10 Then dd="0"&dd
If mm<10 Then mm="0"&mm

If DayOfYear<10 Then DayOfYear="0"&DayOfYear
If DayOfYear<100 Then DayOfYear="0"&DayOfYear

DateStamp=mm&dd&yyyy
wscript.echo "Datestamp "&DateStamp
FileName="outputlog."&DateStamp&".txt"
wscript.echo "Filename "&FileName

DoYstamp=DayOfYear&yy
wscript.echo "DoYstamp "&DoYstamp
FileName="outputlog."&DoYstamp&".txt"
wscript.echo "Filename "&FileName




Thanks all. This is what I needed. I do appreciate the help.
2215.

Solve : UNDO command in VB?

Answer»

hey guyz, im really stuck trying to create an undo command in vb to remove a previous GRAPHIC.... any help WOULD be great SAVE the every CHANGES in graphic to a separate storage(like in file). Then RECALL them at every undo command.

2216.

Solve : TcpListener only working locally?

Answer»

Ok, so I have some code, a server and a client, which connect together just fine on a LOCAL network or single COMPUTER. But when I try to connect to it over the internet, it just SAYS "The target machine actively refused the connection."

I'm working in vb.net 2008.

What I'm wondering is, what IP address am I supposed to feed the tcplistener and the tcpclient? When I have them running on the same computer, I give them both 127.0.0.1 and they connect fine.

They are connecting/listening to the same port (500)



you would need to give the TCP Listener the ip address you have been assigned by your ISP - not the usual 192.168.x.x but something specific to your ISP account - such as 71.168.123.124ok, for the purposes of this, lets say i went to www.whatismyip.com and they said it was 1.2.3.4

I feed this into my program, the tcplistener rejects this (apparently you can only use the local address)

I feed it into my tcpclient, this tries to connect to it while the tcplistener is running, however, it is also rejected, "the host machine actively refused the connection."

What is BLOCKING it? when i did this i tried EVERYTHING, closed all the firewalls etc...

2217.

Solve : help needed with the pseudocode.plz?

Answer»

Dear all,

to start with, im not asking for a code...im just too lost and need someone to guide me.

can anybody help me think about implementing a hash table to store MEMORY addresses and times for stores, and to look up matching addresses and times in the hash table for loads.

well i wana try to build "memory model " (model it on a store and load instructions) using a hashtable , by the "time" i mean the cycle time

your help is HIGHLY appreciated just to clarify things well i need the hash table for the same reason cache implementation uses a hashtable.

memory implementation RESEMBLES that of the cache but its a bit less complicated.

i tried to look at cache implementation..they used hashtable for the cache organization

Within the cache, there are three basic TYPES of organization:

Direct Mapped
Fully Associative
Set Associative


im going to USE the set assocative one...
so basically i want a general pseudocode for the memory implementation (for any kind of cpu)..i'll look for the details later cz i think i'll be WORKIN for the x86.

2218.

Solve : help creating a 2 dimensional array! in c++?

Answer»

how to create a w64 structure in c++?

im want to try to implement a memory model for the a simulator.

so basically, the memory will be implemented as an 8 associative set ARRAY : MEANING a two dimensional array where the first dimension is the 2^14 ( that is 16k) and the other is 8 ( which is the number of ways)

since this simulator is written in C++ with extensive use of x86 and x86-64 inline assembly code, i have to create a w64 structure and the array will be of that type.

each entry will have the cycle time of the simulator and the address of the instruction

can anybody help with the creation of the type and the array?
your help is HIGHLY appreciated

2219.

Solve : Plz tell, urgent(Assembly language)??

Answer»

How can we get our name in reverse order in a Assembly LANGUAGE, like Maria...airam
plz show the code, Tommorow is my exam, its a QUESTION i need to practice, most PROBABLY this type of question could be asked in exam. Thanks

No Homework helping.

But here:http://www.xs4all.nl/~smit/asm01001.htmWe can help users with their homework........But not directly. It's always best if they FIND out the answers for themselves, not by someone else telling them.Store the ASCII bytes in an area of memory, one by one M, a, r, i, a
Reserve another area of memory with the same number of bytes.
Set a pointer equal to the LENGTH of the name.
[:start] get the character of the name pointed to by (memory1 start + pointer)
put it in memory location pointed to by (memory2 finish - pointer)
decrement the pointer
if the pointer is not zero jump to :start
The end.

2220.

Solve : Batch file checking if folder exist then add $foldername$1?

Answer»

Hello,

Basically, i want to make a BATCH file that checks if a folder exists, and if it does, create the same folder but with a 1 (or 2 if 1 exists, 3 if 2 exists and so on) at the end. Or maybe make it foldername with the date at the end.

I am making this for a little batch program that automatically copy's my music folder, and those of my friends, by only plugging my USB drive in their computer (with permission ofcourse ).

THANKS in advance!Rather than testing for a folder, why not ask for a new folder name? If you are going to insert the USB thing by hand, TAKE a few seconds to give a descriptive name. Otherwise, soon have two dozen folders like this
mp3(1)
mp3(2)
mp3(3)
mp3(4)
mp3(5)
...
Would your rather not have:
Andy.mp
Cool.mp
Easy.mp
Far-Out.mp
Hervey.mp
Think about it.
There are some things you really don't want the computer to do.
Like classify your music TASTE.

2221.

Solve : Duplicate Error/Bug, but not harmful(I Hope) just irritating??

Answer»

Hi everytime I use a USB thumb drve or flash disk this ALWAYS happen. Ive newly reformatted my computer and installed AVG 8.5 FREE Edition and it still happens. It also started before I reformatted my computer. Also theres a removable drive showing but when SELECTED says "insert disk" when there arent any usb disk drives attached.

Windows XP SP3
1GB Ram
160GB HDD

EDIT: SORRY the image didnt com out right so i have to FIX it

It thinks your USB device is a card reader or similar device.
Try to un install the USB device it says you have. NOPE Doesn't work, I tried uninstalling and reinstalling the drivers and still the same problem. Thinking of a card reader reminds me the only thing attached that's common to two of my computers(using the same OS installer) is that the mouse we use is a USB optical mouse the rest are for printers and a webcam.I imagine the issue is the multiple shell folder items such as Printers and Faxes and Network connections?Um... I don't really understand what it is, so I tried looking about it somewhere else but all I found are software that's not even needed.

2222.

Solve : learn ois for c++?

Answer»

Lately i have been LOOKING for a SIMPLE input library for C++ and i found ois, but i couldn't find any documentation, and the wiki wasn't WORKING, so can someone tell me where i can learn about it?

2223.

Solve : Executing different methods in a Jar file?

Answer»

A jar FILE has many METHODS in it. When I run the following: java -jar TheProgram.jar T the main method in TheProgram is executed with a parameter of T.

Is there a way to execute one of the other methods in TheProgram.jar, say otherMethod(), by saying something like java -jar TheProgram.jar /otherMethod T?

Thank you.Is this a homework assignment?
Basically a JAR is a compressed file that can have java applets.
Have you ALREADY read this page?
http://java.sun.com/developer/Books/javaprogramming/JAR/basics/
If you had, I don't understand your question. If a method is manifest yopur COULD use it, otherwise no.
But if the jar file is not locked, you can MODIFY or extract what you want and put it into a new jar or some other form.No this is not a homework assignment, No I Had not read the page. I can use the java -cp theprogram.jar form.

2224.

Solve : How Do I change one letter in one string mulitiple times? Help??

Answer»

Ok for thoes that don't UNDERSTAND the title I want to do this...

Nvm I looked on google for an hour and a half and found a really easy way of doing it I hope this will HELP other people with questions like me =D

using System;

public class EXAMPLE
{
public static void Main()
{
STRING Word = "Hello how";
string Words = "Hre You TodHy?";
//Easy Way
string TransWords = Words.Replace("H", "A");
//Easy Way
string Sentence = Word + TransWords;
Console.WriteLine(Sentence);
Console.ReadLine();
}
}

What would I put for the Code?
SOLVED

2225.

Solve : Referencing a specific file creation date in a .bat or .vbs?

Answer»

I am attempting to create a script that checks if a file's creation date is x days old. If the file is x days old, then I need to execute the file and delete the script. It is unnecessary to delete the file itself.

I have seen many solutions online for creating a batch/vbs that checks ALL files in a folder and deletes the ones that are x days old. This is not my intended function...hopefully someone here has a suggestion for me...

I would prefer to do this in a batch file...but I have heard that vbs would be a better solution for scripts attempting to call date variables. I'm open to either method, but I need to USE a switch when running the exe.vbs version:
1. check x days old: datediff function, combine with datecreated property
2. execute file: .run method or .exec method
3. delete file: delete or deletefile method

batch version:
1. check x days old: use julian-gregorian math, combine with dir/tc
2. execute file: call,start method or just type the filename
3. delete file: del

if you post your batch/vbs script, along with explanation on what you want.Code: [Select]Public Function DeleteOldFiles(5 DaysOld As LONG, FileSpec As _
String,Optional ComparisonDate As Variant) As Boolean

'PURPOSE: DELETES ALL FILES THAT ARE DaysOld Older than
'ComparisonDate, which defaults to now

'RETURNS: TRUE, if succesful
'False otherwise (e.g., user passes non-date argument
'deletion fails because file is in use,
'file doesn't exist, etc.)

'will not delete readonly, hidden or system files

Dim sFileSpec As String
Dim dCompDate As Date
Dim sFileName As String
Dim sFileSplit() As String
Dim iCtr As Integer, iCount As Integer
Dim sDir As String

sFileSpec = FileSpec

If IsMissing(ComparisonDate) Then
dCompDate = Now
ElseIf Not IsDate(ComparisonDate) Then
'client passed wrong type
DeleteOldFiles = False
Exit Function
Else
dCompDate = CDate(Format(ComparisonDate, "mm/dd/yyyy"))
End If

sFileName = Dir(sFileSpec)

If sFileName = "" Then
'returns false is file doesn't exist
DeleteOldFiles = False
Exit Function
End If

Do

If sFileName = "" Then Exit Do

If InStr(sFileSpec, "\") &GT; 0 Then
sFileSplit = Split(sFileSpec, "\")
iCount = UBound(sFileSplit) - 1
For iCtr = 0 To iCount
sDir = sDir & sFileSplit(iCtr) & "\"
Next

sFileName = sDir & sFileName
End If

On Error GoTo errhandler:
If DateDiff("d", FileDateTime(sFileName), dCompDate) _
>= DaysOld Then

Kill sFileName

End If

sFileName = Dir
sDir = ""
Loop

DeleteOldFiles = True

Exit Function

errhandler:
DeleteOldFiles = False
Exit Function
End Function

That's what I'm working from in VBS...but I have no idea where to go from here. The code is from freevbcode (http://www.freevbcode.com/ShowCode.Asp?ID=77). I've been tinkering with VB script for the first time this week and I've accomplished some basic tasks like changing where I want my My Documents targeted but this time comparison is proving difficult for me...even while referencing msdn frequently.

Here's what I want blah.vbs to do exactly:
If "C:\myfile.exe" is 5 days old, run "C:\myfile.exe /silent" and delete "C:\blah.vbs"

I'll end up changing the paths so I can put blah.vbs in the startup folder...but I think that gets my idea across.After spending some time with your suggestions...I've come up with this. What do you think?

Code: [Select]dim filesys, filetxt, f, WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Set filesys = CreateObject("Scripting.FileSystemObject")
Set f = filesys.GetFile("C:\Basic_admin.exe")

If DateDiff("d",f.DateCreated,Now) >= 5 Then
WshShell.Exec "C:\Basic_admin.exe /install"
filesys.DeleteFile "C:\documents and settings\administrator\start menu\programs\startup\freezeit.vbs"
Else
wscript.echo "Your computer will remain thawed for " & 5 - DateDiff("d",f.DateCreated,Now) & " more days. Be sure to have all devices installed before then!"
End if

QUOTE from: MrQuincy on April 02, 2009, 04:49:46 PM

After spending some time with your suggestions...I've come up with this. What do you think?

Code: [Select]dim filesys, filetxt, f, WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Set filesys = CreateObject("Scripting.FileSystemObject")
Set f = filesys.GetFile("C:\Basic_admin.exe")

If DateDiff("d",f.DateCreated,Now) >= 5 Then
WshShell.Exec "C:\Basic_admin.exe /install"
filesys.DeleteFile "C:\documents and settings\administrator\start menu\programs\startup\freezeit.vbs"
Else
wscript.echo "Your computer will remain thawed for " & 5 - DateDiff("d",f.DateCreated,Now) & " more days. Be sure to have all devices installed before then!"
End if

Lol, you just answer your own question. this is excellent, since you write it yourself, it's easier for you to maintain the code. nice script Assuming you want the script to delete itself,

This would need editing if the name changed:

Code: [Select]filesys.DeleteFile "C:\documents and settings\administrator\start menu\programs\startup\freezeit.vbs"
This would not:

Code: [Select]filesys.DeleteFile "Wscript.ScriptFullName"Quote from: Dias de verano on April 03, 2009, 05:17:24 AM
Assuming you want the script to delete itself,

This would need editing if the name changed:

Code: [Select]filesys.DeleteFile "C:\documents and settings\administrator\start menu\programs\startup\freezeit.vbs"
This would not:

Code: [Select]filesys.DeleteFile "Wscript.ScriptFullName"


HA HA! it would so!

Code: [Select]filesys.DeleteFile Wscript.ScriptFullName
to remove the quotes at least Quote from: BC_Programmer on April 03, 2009, 01:26:09 PM

HA HA! it would so!

Code: [Select]filesys.DeleteFile Wscript.ScriptFullName
to remove the quotes at least

Indeed. Good catch.
2226.

Solve : windows XP pro, service doesnot to start!?

Answer»

I created a SERVICE in windows XP and linked it to a batch file that i have created, however whenever i try to start the created service it gives me an error:

"error 1053: the service didnot respond to the start or control request in timely fashion"

i have tried setting it to automatic and restarting the computer but it didnot SOLVE the issue. PLEASE HELP!

winXP pro SP3
256mb RAM
80gb HDD
3ghz processor

[attachment deleted by admin]The ServiceBase class CALLS the OnStop method directly from the Service command handler that is defined in the ScDispatcherLoop of the Advapi32.dll file. After 30 seconds, if the ScDispatcherLoop thread is not ready to receive a new service command from the service control manager, Windows Service Controller marks the service as "time out." Therefore, you receive this error message. .... therefore .... to repair this problem you will need to GET a sp update . hope that will help you out some

2227.

Solve : VB 2008 MenuStripItem?

Answer»

I have a project that I added a MenuStrip too. 1 of my menu items is SUPPOSED to make a label hide or display.
Originally this is my code ( which does work, just not quite the way I want)
LabelToolStripMenuItem.Checked = NOT(LabelToolStripMenuItem.Checked)
MessageLabel.Visible = LabelToolStripMenuItem.Checked

Now this does work but it will close the Menu upon checking the menu item. I am TRYING to get it to STAY open so I can check or uncheck without have to go back into the Menu, make sense?

I have tried
If LabelToolStripMenuItem.Checked then
MessageLabel.Visible = True
Else
LabelToolStripMenuItem.Checked = False
End if


its not working(

Tour

'ifs are overkill, but for the record you've got it backwards:


Code: [SELECT]If Not LabelToolStripMenuItem.Checked then
MessageLabel.Visible = True
Else
LabelToolStripMenuItem.Checked = False
End if

but, you can just as easily do this:



Code: [Select]LabelToolStripMenuItem.Checked = Not LabelToolStripMenuItem.Checked




Thanks)
I think I will leave as this:

LabelToolStripMenuItem.Checked = NOT(LabelToolStripMenuItem.Checked)
MessageLabel.Visible = LabelToolStripMenuItem.Checked

It works so why mess with it? HEHE good call, didn't see the visible property call there; thought they were both checked calls.

2228.

Solve : If case insensitive VB.NET?

Answer»

Is there a way in VB.NET to compare strings with an if statement without case sensitivity. like in MS-DOS batch with the /I switch?
strcomp function- or I believe there is a String.Compare() method as well.


Code: [Select]if StrComp(StringA,StringB,vbTextCompare)=0 then
'they are the same
end if

but of course .NET is moving away from such foolish notions as "functions". No, everything must now be methods and properties:

Code: [Select]If String.Compare(StringA,StringB,True)=0 then
'the same.

end if



Or, use the CompareTo() Method:

Code: [Select]if StringA.CompareTo(StringB,True)=0 then
'the same
end if


Note that you can even do this:

Code: [Select]If "ABCDEFG".CompareTo(StringA,True)=0 Then
'StringA is "ABCDEFG", or a lowercased equivalent
End If


Personally I NEVER use the equality operator to test strings- except for single-character strings or when I'm to lazy to write out a StrComp() call. StrComp is far better, especially in VB6, since the entire behaviour of the program could change- or the program could break- if the "Option Compare" is changed.or is there ucase function in vb.net??

Code: [Select]if ucase(str1)=ucase(str2) then
'equal
end ifNEVER use that.

performing two uppercase operations takes longer then the StrComp Function- the Ucase and Lcase functions are designed for changing the entire string to Upper or lower case; the strcomp() function is designed for comparing strings. For example if Strcomp finds the first two characters are different, it returns -1 or 1 and returns. using ucase or lcase means that the function will need to convert both strings, and the equality operator will invoke a comparison, and THEN it will return false. And given that this is .NET Ucase and Lcase have bugs and are slower then the .ToUpperCase and .ToLowerCase Methods.

Although using StrComp() obviously isn't an option with QuickBasic, since it's been offered in VB since I believe Version 3 or 4, there is no reason not to use it.


Additionally, using Lcase or Ucase has other performance complications as well. For example, this code:

Code: [Select]Select Case StrComp(A,b,vbtextCompare)
Case -1
Msgbox "A is smaller then B"
case 0
Msgbox "A and B are equal"
case 1
Msgbox "A is larger then B"
end Select

will execute faster then this:

Code: [Select]Au = Ucase$(A)
Bu = Ucase(B)
if Au < Bu Then
msgbox "A is larger then B
Elseif Au=Bu Then
Msgbox "A and B are equal"
Else
Msgbox A is Smaller then B"
end if

1. Ucase is performed on both strings, regardless of how far along the string they are the same. for example if we had strings of millions of characters, Ucase must go through every single character and perform the appropriate conversion. (realistically it likely calls the CharToLowerW API routine- or whatever the routine is called, but regardless a Loop is performed SOMEWHERE). The conversion of course is not a brainless addition of 32 or subtraction of 32, because it also involves special cases of Accent characters.

2. StrComp() iterates through each character in the string- the moment it finds a difference based on the given comparison, (also likely involving a UCase/Lcase or equivalent), it breaks out. THIS is important- the strcomp function is specially constructed to break out once it knows the answer to the function- (IE, characters differ). the Ucase=Ucase or Lcase-Lcase method converts both strings, and then performs a compare, which can be costly in tight loops, time-sensitive operations and can also be expensive in terms of memory if the strings are large- why?

in my example USAGE, two temporary variables are created to prevent more then one call of Ucase$. each one will be the same size as the corresponding value. calling functions and comparing their results directly wouldn't reduce the memory load since VB will generate temporary variables which is uses during evaluation.

ok, i got your point.

Quote from: BC_Programmer on March 30, 2009, 11:28:53 PM

2. StrComp() iterates through each character in the string- the moment it finds a difference based on the given comparison, (also likely involving a UCase/Lcase or equivalent), it breaks out. THIS is important- the strcomp function is specially constructed to break out once it knows the answer to the function- (IE, characters differ).
although this is just an assumption that the code break out on first occurance. but i believe the microsoft guys do break the loop on first occurance.

how many bytes is one character?
if 1 byte, comparing char a-z lower-uppercase is as simple as toggling the 6th bit.
if 2 byte, then

thus vb.net syntax reminds me of java.it's not an assumption- it's the only explanation for it running faster. Also- it would be dumb to do otherwise.


toggling the 6th bit won't work, either.

since that is simply subtracting or adding 32. what about non-alphabetic characters?

toggling the 6th bit on the exclamation mark, code 33, makes it 1, a control character.

All Strings in Visual BASIC, and the .NET languages are Unicode, and thus 2 bytes. They can be treated as ANSI, but dealing with the unicode itself via lenb, chrb and ascb is fully possible.

Regarding conversion of case this is provisioned by various mapping routines. Since all ANSI characters are easily converted to unicode by using 0 in the high word of the equivalent unicode character- (for example, ANSI A is chr$(&H41), Unicode A is ChrB$(0) & ChrB$(&H41).

Thankfully VB converts to and fro as NECESSARY, which to be honest can be a pain in the *censored*, since in order to pass the string as an actual Unicode string to an API routine one needs to instead pass a Long pointer to the string. Oh well.

Quote
thus vb.net syntax reminds me of java.

That's probably just the object-oriented ness of them both.


in a similar vein via my BCFile file library I can do this:

Code: [Select]filesystem.CreateFile("C:\Windows\test.dat").OpenAsBinaryStream(GENERIC_WRITE,FILE_SHARE_DELETE+FILE_SHARE_READ,CREATE_NEW,FILE_FLAG_SEQUENTIAL_SCAN).WriteString("text!")

given it's a little messier then using the FileSystemObjects, but the FileSystemObjects don't support showing the right-click explorer menu like my library does... as well as a few other things, like alternate Data stream enumeration.


Back on topic, however- the StrComp() function is preferable simply because it takes account of unicode differences, for example the special characters that combine other characters such as Æ (ligatures) I believe are compared equal to the expanded version.



BC, i bought that explanation. you have put up a good point.
i am going to use strcomp() today onwards, especially for intense string-worker loop.It definitely speeds things up, thats for sure. I got lazy in a few comparisons in my Expression evaluator and used Ucase for a few comparisons; after replacing them the routine, although called over 10000 times to parse a complicated expression, decreased it's total time to almost half, even though I was using StrComp() in most places.

Also, it looks like .NET has a few overloads for "Compare", to allow for a LocaleID.

Another interesting string manipulation is counting the occurences of a string within another string- in one line:

Code: [Select]Public Function CountStr(Byval SearchIn as String,SearchFor as String) as Long
CountStr = (Len(searchin) - Len(replace$(searchin,searchfor,""))/Len(searchfor)
End Function

The Replace$() function is so useful.

So StringComp is the one i should use?With VB.NET, StrComp() is just in there for compatibility.

Use the Static String.Compare or CompareTo() Methods, as I show in my first post.

The "old" functions are there purely for compatibility, and in fact the Lcase() function as provided as a subtle bug, in that the Lcase$(nothing)=Nothing, yet the Ucase(nothing)=""...

MS won't waste time fixing these bugs- nowadays EVERYTHING must be in a object...

*Sigh* as much as I love object oriented programming, Some operations simply don't require instance data. I wonder if the .NET framework version 6 will have replaced all the string static methods with classes. I can see it now. classes like CLStringToUpper,ClStringToLower and so forth, all requiring the passing of the string in the constructor and retrieving the Lcased/Ucased value via a property.Or model it like Batch's If statement with the /I switch, to not compare it by case. Quote from: macdad- on March 31, 2009, 05:39:04 PM
Or model it like Batch's If statement with the /I switch, to not compare it by case.


wat.

No BC, the method you give is not faster. You are so very WRONG. I am disappointed in you.
Because he had to read your post and come back and you had to come back, That takes time.

Going for minor improvement of run-time execution speed is a poor programming practice unless speed is a know issue. Speed of development and deployment and correct documentation take precedence over a millisecond in a project that takes days.

Don't include speculation in your observations without say hing that is an apparent observation.
With Microsoft libraries thane is not easy way to know what they were thinking when they did the code. It is not Open Source. We are not allowed to see it. If you could see it, you might take a line from Bill Gates,: "That's the dumbest thing I ever saw!"
Also, it's interesting to note that trying to duplicate the StrComp() function with this:

Code: [Select]Private Function StrCompA(ByVal StringA As String, ByVal StringB As String, comparemethod As VbCompareMethod) As Integer


If comparemethod = vbTextCompare Then
StringA = UCase$(StringA)
StringB = UCase$(StringB)
End If
If StringA < StringB Then
StrCompA = -1
ElseIf StringA = StringB Then
StrCompA = 0
Else
StrCompA = 1
End If

End Function


Is FUNDAMENTALLY broken.

If the Option Compare Text is used at the module level, you cannot use this StrComp() replacement to perform Case-sensitive comparisions.


Also, just as I said- the call to Ucase twice as well as the use of several comparison operators drags performance down. Trust me- when it comes to Core-level routines- microseconds count, because those microseconds add up, especially in core-level routines.

Quote
It definitely speeds things up, thats for sure. I got lazy in a few comparisons in my Expression evaluator and used Ucase for a few comparisons; after replacing them the routine, although called over 10000 times to parse a complicated expression, decreased it's total time to almost half, even though I was using StrComp() in most places.

THIS was NOT speculation. I saw it with my own eyes. NOTHING else in my library changed except for a accidental "=" that I changed to an StrComp(String,String,vbtextcompare) = 0.

it is NOT speculation.


note I've stripped the prolog from this dissassembly- or so it seems, anyway.

Dissassembly of StrComp in MSVBVM60.dll:


Code: [Select] 734E7A2D: 83 7E 14 00 cmp dword ptr [esi+14h],0
734E7A31: 76 39 jbe 734E7A6C
734E7A33: 8B 46 18 mov eax,dword ptr [esi+18h]
734E7A36: 8B 04 B8 mov eax,dword ptr [eax+edi*4]
734E7A39: 85 C0 test eax,eax
734E7A3B: 74 23 je 734E7A60
734E7A3D: 8B 08 mov ecx,dword ptr [eax]
734E7A3F: 8D 55 0C lea edx,[ebp+0Ch]
734E7A42: 52 push edx
734E7A43: 53 push ebx
734E7A44: 50 push eax
734E7A45: FF 11 call dword ptr [ecx]
734E7A47: 85 C0 test eax,eax
734E7A49: 75 15 jne 734E7A60
734E7A4B: 8B 45 0C mov eax,dword ptr [ebp+0Ch]
734E7A4E: 3B 45 FC cmp eax,dword ptr [ebp-4]
734E7A51: 75 07 jne 734E7A5A
734E7A53: C7 45 F8 01 00 00 mov dword ptr [ebp-8],1
00
734E7A5A: 8B 08 mov ecx,dword ptr [eax]
734E7A5C: 50 push eax
734E7A5D: FF 51 08 call dword ptr [ecx+8]
734E7A60: 83 7D F8 00 cmp dword ptr [ebp-8],0
734E7A64: 75 06 jne 734E7A6C
734E7A66: 47 inc edi
734E7A67: 3B 7E 14 cmp edi,dword ptr [esi+14h]
734E7A6A: 72 C7 jb 734E7A33
734E7A6C: 8B 4D FC mov ecx,dword ptr [ebp-4]
734E7A6F: EB 9F jmp 734E7A10
734E7A71: 55 push ebp
734E7A72: 8B EC mov ebp,esp
734E7A74: 83 EC 24 sub esp,24h
734E7A77: 8B 45 24 mov eax,dword ptr [ebp+24h]
734E7A7A: 53 push ebx
734E7A7B: 33 DB xor ebx,ebx
734E7A7D: 56 push esi
734E7A7E: 3B C3 cmp eax,ebx
734E7A80: 57 push edi
734E7A81: 8B F1 mov esi,ecx
734E7A83: 74 06 je 734E7A8B
734E7A85: C7 00 01 00 00 00 mov dword ptr [eax],1
734E7A8B: 8B 06 mov eax,dword ptr [esi]
734E7A8D: 56 push esi
734E7A8E: FF 50 04 call dword ptr [eax+4]
734E7A91: 8B 45 08 mov eax,dword ptr [ebp+8]
734E7A94: 8B 4D 0C mov ecx,dword ptr [ebp+0Ch]
734E7A97: 8B 55 18 mov edx,dword ptr [ebp+18h]
734E7A9A: 89 45 DC mov dword ptr [ebp-24h],eax
734E7A9D: 8B 45 10 mov eax,dword ptr [ebp+10h]
734E7AA0: 89 4D E0 mov dword ptr [ebp-20h],ecx
734E7AA3: 89 45 E4 mov dword ptr [ebp-1Ch],eax
734E7AA6: 8B 45 14 mov eax,dword ptr [ebp+14h]
734E7AA9: 83 F8 02 cmp eax,2
734E7AAC: 89 45 E8 mov dword ptr [ebp-18h],eax
734E7AAF: 89 55 EC mov dword ptr [ebp-14h],edx
734E7AB2: 89 5D F0 mov dword ptr [ebp-10h],ebx
734E7AB5: 89 5D F4 mov dword ptr [ebp-0Ch],ebx
734E7AB8: 89 5D F8 mov dword ptr [ebp-8],ebx
734E7ABB: 89 5D FC mov dword ptr [ebp-4],ebx
734E7ABE: 76 4C jbe 734E7B0C
734E7AC0: 68 57 00 04 60 push 60040057h
734E7AC5: FF 15 C8 11 42 73 call dword ptr ds:[734211C8h]
734E7ACB: 33 DB xor ebx,ebx
734E7ACD: 39 5D F8 cmp dword ptr [ebp-8],ebx
734E7AD0: 74 2D je 734E7AFF
734E7AD2: 33 FF xor edi,edi
734E7AD4: 39 5D 1C cmp dword ptr [ebp+1Ch],ebx
734E7AD7: 76 16 jbe 734E7AEF
734E7AD9: 8B 45 F8 mov eax,dword ptr [ebp-8]
734E7ADC: 8B 04 B8 mov eax,dword ptr [eax+edi*4]
734E7ADF: 3B C3 cmp eax,ebx
734E7AE1: 74 06 je 734E7AE9
734E7AE3: 8B 08 mov ecx,dword ptr [eax]
734E7AE5: 50 push eax
734E7AE6: FF 51 08 call dword ptr [ecx+8]
734E7AE9: 47 inc edi
734E7AEA: 3B 7D 1C cmp edi,dword ptr [ebp+1Ch]
734E7AED: 72 EA jb 734E7AD9
734E7AEF: FF 75 F8 push dword ptr [ebp-8]
734E7AF2: 53 push ebx
734E7AF3: FF 35 CC E7 52 73 push dword ptr ds:[7352E7CCh]
734E7AF9: FF 15 94 12 42 73 call dword ptr ds:[73421294h]
734E7AFF: 8B 06 mov eax,dword ptr [esi]
734E7B01: 56 push esi
734E7B02: FF 50 08 call dword ptr [eax+8]
734E7B05: 5F pop edi
734E7B06: 5E pop esi
734E7B07: 5B pop ebx
734E7B08: C9 leave
734E7B09: C2 24 00 ret 24h


unfortunately between the compiler optimizations and the fact that dissassembly cannot preserve the original symbols, the original meaning is hard to determine. There are several jumps that skip large sections; additionally it calls the OLE functions for string comparison, which is not surprising.

The fact that StrComp() works AND is faster then a less robust "capitalization" scenario tells us that SOMETHING is different between the two methods. It's fairly apparent that it simply doesn't waste time copying two string variables to be uppercase, analyzing the two strings (possibly determining a difference between them early on, thus causing the time spent on uppercasing (or whatever) to the strings a complete waste of time.



The main reason for using StrComp() over some silly Ucase or Lcase kludge would be the fact that Ucase and Lcase aren't Turing complete and fail in several relatively benign scenarios, generally involving the fact that Ucase$() acts on the ANSI value which can cause compare errors with common Unicode symbols that are otherwise compared properly with Strcomp(). An additional fact adding to this is my previously explained ligature comparison ability.


So really- aside from the fact that it's both faster and does a better job, and implements Locale-specific functionality I guess there is no reason to use StrComp over capitalizing (or lcasing) both of them.


Or, we could use the string comparision Class found on VBSpeed:

Code: [Select]' By Chris Lucas, [emailprotected], 20011204/20020607
' Thanks to Olaf for the class implementation concept

Option Explicit

Private Declare Function ArrPtr& Lib "msvbvm60.dll" Alias "VarPtr" (ptr() As Any)
Private Declare Sub RtlMoveMemory Lib "kernel32" (dst As Any, src As Any, ByVal nBytes&)

Private Header1(5) As Long
Private Header2(5) As Long
Private SafeArray1() As Long
Private SafeArray2() As Long


Private Sub Class_Initialize()
' Set up our template for looking at strings
Header1(0) = 1 ' Number of dimensions
Header1(1) = 4 ' Bytes per element (long = 4)
Header1(4) = &H7FFFFFFF ' Array size

' Force SafeArray1 to use Header1 as its own header
RtlMoveMemory ByVal ArrPtr(SafeArray1), VarPtr(Header1(0)), 4

' Set up our template for look at search text
Header2(0) = 1 ' Number of dimensions
Header2(1) = 4 ' Bytes per element (long = 4)
Header2(4) = &H7FFFFFFF ' Array size

' Force SafeArray1 to use Header1 as its own header
RtlMoveMemory ByVal ArrPtr(SafeArray2), VarPtr(Header2(0)), 4
End Sub


Private Sub Class_Terminate()
' Make SafeArray1 once again use its own header
' If this code doesn't run the IDE will crash
RtlMoveMemory ByVal ArrPtr(SafeArray1), 0&, 4
RtlMoveMemory ByVal ArrPtr(SafeArray2), 0&, 4
End Sub


Friend Function IsSameText03(String1 As String, String2 As String, Compare As VbCompareMethod) As Boolean
' By Chris Lucas, [emailprotected], 20011204
Dim i&, SLen&, tmp1&, tmp2&, tmp3&, tmp4&, alt&

SLen = LenB(String1)
If SLen <> LenB(String2) Then Exit Function

Header1(3) = StrPtr(String1): Header2(3) = StrPtr(String2)

If Compare = vbTextCompare Then
For i = 0 To SLen \ 4 - 1
tmp1 = SafeArray1(i)
tmp2 = (tmp1 And &HFFFF&)
tmp3 = SafeArray2(i)
tmp4 = (tmp3 And &HFFFF&)


Select Case tmp2
Case 97& To 122&: alt = tmp2 - 32
Case 65& To 90&: alt = tmp2 + 32
Case 49&: alt = 185
Case 50&: alt = 178
Case 51&: alt = 179
Case 138&: alt = 154
Case 140&: alt = 156
Case 142&: alt = 158
Case 154&: alt = 138
Case 156&: alt = 140
Case 158&: alt = 142
Case 159&: alt = 255
Case 178&: alt = 50
Case 179&: alt = 51
Case 185&: alt = 49
Case 192& To 214&: alt = tmp2 + 32
Case 216& To 222&: alt = tmp2 + 32
Case 224& To 246&: alt = tmp2 - 32
Case 248& To 254&: alt = tmp2 - 32
Case 255&: alt = 376
Case 338&: alt = 339
Case 339&: alt = 338
Case 352&: alt = 353
Case 353&: alt = 352
Case 376&: alt = 255
Case 381&: alt = 382
Case 382&: alt = 381
End Select


If alt <> tmp4 Then
If tmp2 <> tmp4 Then Exit Function
End If
tmp2 = (tmp1 And &HFFFF0000)
tmp4 = (tmp3 And &HFFFF0000)
Select Case tmp2
Case &H610000 To &H7A0000: alt = tmp2 - &H200000
Case &H410000 To &H5A0000: alt = tmp2 + &H200000
Case &H310000: alt = &HB90000
Case &H320000: alt = &HB20000
Case &H330000: alt = &HB30000
Case &H8A0000: alt = &H9A0000
Case &H8C0000: alt = &H9C0000
Case &H8E0000: alt = &H9E0000
Case &H9B0000: alt = &H8A0000
Case &H9C0000: alt = &H8C0000
Case &H9E0000: alt = &H8E0000
Case &H9F0000: alt = &HFF0000
Case &HB20000: alt = &H320000
Case &HB30000: alt = &H970000
Case &HB90000: alt = &H310000
Case &HC00000 To &HD60000: alt = tmp2 + &H200000
Case &HD80000 To &HDE0000: alt = tmp2 + &H200000
Case &HE00000 To &HF60000: alt = tmp2 - &H200000
Case &HF80000 To &HFE0000: alt = tmp2 - &H200000
Case &HFF0000: alt = &H1780000
Case &H1520000: alt = &H1530000
Case &H1530000: alt = &H1520000
Case &H1600000: alt = &H1610000
Case &H1610000: alt = &H1600000
Case &H1780000: alt = &HFF0000
Case &H17D0000: alt = &H17E0000
Case &H17E0000: alt = &H17D0000
End Select
If alt <> tmp4 Then
If tmp2 <> tmp4 Then Exit Function
End If
Next i

If (LenB(String1) \ 2 And 1) Then
tmp2 = (SafeArray1(i) And &HFFFF&)
tmp4 = (SafeArray2(i) And &HFFFF&)

Select Case tmp2
Case 97& To 122&: alt = tmp2 - 32
Case 65& To 90&: alt = tmp2 + 32
Case 49&: alt = 185
Case 50&: alt = 178
Case 51&: alt = 179
Case 138&: alt = 154
Case 140&: alt = 156
Case 142&: alt = 158
Case 154&: alt = 138
Case 156&: alt = 140
Case 158&: alt = 142
Case 159&: alt = 255
Case 178&: alt = 50
Case 179&: alt = 51
Case 185&: alt = 49
Case 192& To 214&: alt = tmp2 + 32
Case 216& To 222&: alt = tmp2 + 32
Case 224& To 246&: alt = tmp2 - 32
Case 248& To 254&: alt = tmp2 - 32
Case 255&: alt = 376
Case 338&: alt = 339
Case 339&: alt = 338
Case 352&: alt = 353
Case 353&: alt = 352
Case 376&: alt = 255
Case 381&: alt = 382
Case 382&: alt = 381
End Select

If tmp2 <> tmp4 Then
If alt <> tmp4 Then Exit Function
End If
End If

IsSameText03 = True
Else
For i = 0 To SLen \ 4 - 1
If SafeArray1(i) <> SafeArray2(i) Then Exit Function
Next i

If (LenB(String1) \ 2 And 1) Then
If (SafeArray1(i) And &HFFFF&) <> (SafeArray2(i) And &HFFFF&) Then Exit Function
End If

IsSameText03 = True
End If
End Function


Friend Function IsSameString02(String1 As String, String2 As String) As Boolean
' By Chris Lucas, [emailprotected], 20020607

Dim i&, Len1&, Len2&, tmp&

' Grab the string lengths
Len1 = LenB(String1) \ 2: Len2 = LenB(String2) \ 2

' Make an informed decision as to whether we should continue
If Len1 <> Len2 Then GoTo BailOut

' Compare the strings
Header1(3) = StrPtr(String1): Header2(3) = StrPtr(String2)
tmp = Len1 \ 2
' The first two characters come cheap
If SafeArray1(i) <> SafeArray2(i) Then GoTo BailOut Else i = i + 1

DoLoop:
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If SafeArray1(i) <> SafeArray2(i) Then GoTo NotEqual Else i = i + 1
If i <= tmp Then GoTo DoLoop

NotEqual:
' some characters don't match, but we need to check to
' see if it happened after the end of the string, a
' nasty side-effect of cascading ifs
If i > tmp Then IsSameString02 = True

BailOut:
' Lengths don't match, let's do absolutely nothing
End Function

this method is twice as fast as StrComp(), which is three times faster then any comparison operator. Since the strCompA() routine I provided earlier implementing the whole uppercasing to test thing uses at LEAST one comparison operator, it will be slower then either of the other methods even in the best case.

Of course it would be silly to use this class except in extremely string-manipulation heavy programs/routines, since it has a tendency to crash during debugging (works 100% compiled).






2230.

Solve : Automatically create new variables during run in VB.NET?

Answer»

Is it POSSIBLE to create a new sepreate variable during run when neccessary?

Like this(in pseudo-code):

Code: [Select]If blahblah = 10 then
Dim &LT;new variable name from textbox value> as <variable type from another textbox value>
End If
Is it possible?

TEST?No, its for a AI program im makingI've tried to do this before, but no, it isn't, what I now use is arrays, because you can define them with whatever LENGTH the program wants.



so use an ArrayList, and I could just name each slot of the ArrayList by a variable name?

2231.

Solve : 3D Camera Algorithms -- XNA?

Answer»

I am using XNA -- Just in case -- Just asking for some sort of algorithm.

I have a camera, say posted at "vector3(0,10,10)", this point is added to the PLAYER's location, successfully achieving a "Stalking camera" Problem is, when the character turns, the camera does not turn --

--How do I have the camera turn with the player's rotation? (Players rotation = CharRotation, Camera's Position = cameraPosition, Player's position = CharPosition)

Liam

Update Method, where the algorithm I am asking for is being put (I know my code is inefficent, I'm working on it.

Code: [Select]protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();

Vector3 mapviewingangle = Vector3.Zero;
Vector3 camadd = Vector3.Zero;
float tf = 0.05f;
KeyboardState kState = Keyboard.GetState();
if (kState.IsKeyDown(Keys.D))
if (camadd.X < 10)
camadd.X += 0.2f;

if (kState.IsKeyDown(Keys.A))
if (camadd.X < -10)
camadd.X += 0.2f;

if (plmovelock == 0){
if (kState.IsKeyDown(Keys.Right))
{
CharRotation -= tf;
}
else if (kState.IsKeyDown(Keys.Left))
{
CharRotation += tf;
}

if (kState.IsKeyDown(Keys.Down))
{
CharPosition.X += (float)(Math.Sin(CharRotation)/7);
CharPosition.Z += (float)(Math.Cos(CharRotation)/7);
}
else if (kState.IsKeyDown(Keys.Up))
{
CharPosition.X -= (float)(Math.Sin(CharRotation)/7);
CharPosition.Z -= (float)(Math.Cos(CharRotation)/7);
}
Window.Title = "[X: " + CharPosition.X + ", Y: " + CharPosition.Y + ", Z: " + CharPosition.Z + "] Map ID: " + map + ", Char Rotat: " + CharRotation + ", CamPos: " + cameraPosition;

if (map == 1)
{
if (CharPosition.Z > 8.2f) CharPosition.Z = 8.1999f;
if (CharPosition.X > 14.2f) CharPosition.X = 14.1999f;
if (CharPosition.Z < -18.0f) CharPosition.Z = -17.9999f;
if (CharPosition.X < -13.0f) map = 2;
if (map == 2) CharPosition = Vector3.Zero;
if (map == 2) CharRotation = 0.0f;
npcPosition1 = new Vector3(1000, 1000, 1000);
}
if (map == 2)
{
if (CharPosition.Z < -20.5f) CharPosition.Z = -20.4999f;
if (CharPosition.X > 21.35f) CharPosition.X = 21.3499f;
if (CharPosition.X < -20) CharPosition.X = -19.9999f;
if (CharPosition.Z > .5f) map = 1;
if (map == 1) CharPosition = new Vector3(-12,0,-4);
if (map == 1) CharRotation = -1.5f;
}
}


//HERE IS WHERE THE ALGORITHM WILL GO


if (CharRotation > 6) CharRotation = 0.0f;
cameraPosition = new Vector3();
base.Update(gameTime);
}so it's a "chase cam" and you want to to appear behind the player a certain distance?

if thats the case, you would need to use a wee bit of trig.


Say you want it X units behind the player, and Y units up. Assume P is the players angle:

If you don't have the player's angle stored anywhere, you can acquire it by solving the right angle triangle formed by your players vector- the X vector and Y vector:

Sin(Angle)= Yvector/XVector

Angle=ArcSin(YVector/Xvector)

*Sigh* of course this might mean implementing the ArcSin Function:

Code: [Select]Arcsin(x) = atan(X)/sqrt(-X * X + 1));


For this I'll assume that the camera isn't following the up-down angle of the player, or that the player doesn't have an up-down movement- if you need that, I might be able to whip something up, but my trig is so rusty right now I'd rather not complicate things unnecessarily

Xdist= Cos(viewangle) * amount
Ydist=Sin(viewangle)*amount

of course you want it to be behind the player so you would multiply these results by -1.

Place the camera Xdist and Ydist away from your player after these calculations, and give it the same angle as provided by the previous functions. (change: I noticed you do have the players rotation stored- that removes that necessary step)Ho-le crap.

I didn't follow ANYTHING PAST "--Assume P is the players angle:"

But chase cam should be enough for me to Google it -- what I did INSTEAD of this was to have the map turn instead of the player-- so the player never really is turning, giving the same effect. =D

2232.

Solve : How many lines?

Answer»

install Gawk for windows, then on the command line
Code: [Select]c:\> gawk 'END{print NR}' file
17

if you want to do programming/batching on windows, get a real programming language. why install third party solution when you can do this in almost any windows-based PC without installing anything.
NT cmd.exe is a powerful interpreter for text based manipulation.

No need to install anything, then on the command line
Code: [Select]C:\>type config.sys|find/c /V ""
2
Quote from: Reno on March 14, 2009, 04:21:19 AM

why install third party solution when you can do this in almost any windows-based PC without installing anything.
We don't live in prehistoric times. Given computing technology today, why is one restricted to what you have. If a tool can reduce hours of coding and increase productivity to the business, its best to use them all to our advantage. A computer is bought just to do that. Increase productivity. Your Windows goes out to the internet for auto updates. That's also installing, isn't it?. What's the difference.

Quote
NT cmd.exe is a powerful interpreter for text based manipulation.

No need to install anything, then on the command line
Code: [Select]C:\>type config.sys|find/c /v ""
2
yes, its powerful, but not powerful enough. It can only do this much, anything more complex, it becomes ugly. try parsing a file and doing complex string manipulations EASILY using cmd.exe (and *.exe in system32). Try doing automated telnetting with proper error control. try grabbing a web page and getting some information out of it. Doing them in batch? no way.Quote from: ghostdog74 on March 14, 2009, 04:04:14 AM
install Gawk for windows, then on the command line
Code: [Select]c:\> gawk 'END{print NR}' file
17

if you want to do programming/batching on windows, get a real programming language.

indeed, I always find it much more convenient to write a vbscript like this:

Code: [Select]set fso = createobject("scripting.filesystemobject")
set fstream = fso.getfile(wsh.arguments(1)).OpenAsTextStream
wsh.echo fstream.readall
fstream.close

instead of the ridiculously difficult to understand:

Code: [Select]type filename

Oh wait- NO I DON'T!


if you've seen some threads were I provide a VBScript solution and Dias provides a batch solution- oddly the batch solution is shorter.

And if you would like to contest wether VBScript is a programming language you might want to take that up with Eric Lieppert.Quote from: BC_Programmer on March 14, 2009, 09:10:30 AM

if you've seen some threads were I provide a VBScript solution and Dias provides a batch solution- oddly the batch solution is shorter.

And if you would like to contest wether VBScript is a programming language you might want to take that up with Eric Lieppert.
you are going OT. Quote from: ghostdog74 on March 14, 2009, 09:03:38 AM
We don't live in prehistoric times. Given computing technology today, why is one restricted to what you have. If a tool can reduce hours of coding and increase productivity to the business, its best to use them all to our advantage. A computer is bought just to do that. Increase productivity. Your Windows goes out to the internet for auto updates. That's also installing, isn't it?. What's the difference.
yes, its powerful, but not powerful enough. It can only do this much, anything more complex, it becomes ugly. try parsing a file and doing complex string manipulations EASILY using cmd.exe (and *.exe in system32). Try doing automated telnetting with proper error control. try grabbing a web page and getting some information out of it. Doing them in batch? no way.

And I'm the one going off-topic? Don't see much about counting the lines in a file there, mostly just a shameless plug for your ridiculous and UNNECESSARY, if not useful, command-line tool of choice. (And no, unnecessary and useful are not mutually exclusive)

Which brings up the fact that windows updates- automatically,, as in, without requiring the user to search for an install a third party tool.

This is Reno's Point- you can make a third party tool as powerful as you want- but if it can be done in something that is included in the default install, whats the point of using a separate tool, third party or otherwise?

your proposed problems are merely invented scenarios devised for the sole purpose of being difficult- if not impossible- via CMD line batch processing commands; except perhaps the first one- since cscript.exe can be used to perform easy string manip via Jscript or VBScript code from batch; and in fact that goes for most of the other proposed "problems".

The funniest part is me and Dias are discussing various ways of performing this task with various levels of compatibility for different newline methods with tools provided in default OS installs and you jump in with a suggestion to install some third party tool and provide some code for it that ACCOMPLISHES nothing more then that which Dias had already provided, except perhaps clutter up their PC with more software installations.

Hubris.Although I quite like fooling around with awk, sed, perl, Ruby etc -- I am getting into Python at the moment -- also the Resource Kits can be useful -- I don't tend to push these others on people here because as you say, BC_Programmer, "if it can be done in something that is included in the default install, whats the point of using a separate tool, third party or otherwise?". Especially if people are prevented from installing 3rd party apps. In fact I get a kind of perverse pleasure in seeing what can be done with the default tools. Quote from: BC_Programmer on March 14, 2009, 12:07:02 PM
And I'm the one going off-topic? Don't see much about counting the lines in a file there, mostly just a shameless plug for your ridiculous and unnecessary, if not useful, command-line tool of choice. (And no, unnecessary and useful are not mutually exclusive)
please read the quote where the reply is directed. A question was asked on "why install a third party ....". I gave the reasons why, mostly for productivity. So where did i go OT? Whereas for your case, since when did i say Vbscript is not a programming language and why should i contest the guy you mentioned? Isn't it going OT ? get your facts right.

Quote
Which brings up the fact that windows updates- automatically,, as in, without requiring the user to search for an install a third party tool.
is searching for a third party tool that difficult?

Quote
This is Reno's Point- you can make a third party tool as powerful as you want- but if it can be done in something that is included in the default install, whats the point of using a separate tool, third party or otherwise?
like i said, productivity. Even in the case of programming tools/languages. If you want to send email in your script, do you write a whole bunch of vbscript code or do you prefer to use things like blat ? That is just an example but if you have ever been a system administrator (or equivalent) that need to perform complex tasks like FTP, telnet to remote and execute jobs etc you will know that you definitely need better tools or Libraries to do your work than using merely cmd.exe

Quote
your proposed problems are merely invented scenarios devised for the sole purpose of being difficult- if not impossible- via CMD line batch processing commands; except perhaps the first one- since cscript.exe can be used to perform easy string manip via Jscript or VBScript code from batch; and in fact that goes for most of the other proposed "problems".
please read my post again. I said "...doing complex string manipulations EASILY...". (sidenote: do you want to have a shot at solving those problems i mentioned using just vbscript.? )

Quote
The funniest part is me and Dias are discussing various ways of performing this task with various levels of compatibility for different newline methods with tools provided in default OS installs and you jump in with a suggestion to install some third party tool and provide some code for it that accomplishes nothing more then that which Dias had already provided, except perhaps clutter up their PC with more software installations.
It's funny because I was replying to the OP and giving an alternative suggestion (and its cross platform). Why should i be bothered about your discussion with Dias since OP didn't even mentioned he can't install 3rd party tools, or whatever you call it.
and wait, so you mean to say i cannot post my suggestions in this forum? I mean, my posts are not meant for you , you know? If my suggestion does not suit the OP, its fine. He has the final say and I am a willing contributor. Its NOT up to you to say anything. Cluttering up the PC? what are you talking about? you mean to say, things like automatic updates which MS downloads from the internet is not cluttering up the PC?? so you mean to say useful tools from the resource kits cannot be used etc?Quote from: Dias DE verano on March 14, 2009, 12:46:10 PM
, "if it can be done in something that is included in the default install, whats the point of using a separate tool, third party or otherwise?".
if i were to say "its for improving workplace productivity", would you accept that as a reasonable answer.
2233.

Solve : C# HELP - Factors of a number.?

Answer»

Quote from: Geek-9pm on February 27, 2009, 11:52:31 AM

Quote
do not hijack somebody elses

And BC, you never do that?

ER... That's different, I "ease" the thread innocently in a different direction.

And I usually have accomplices.hello guyz... i need your help??? what is wrong in this program>>>
when I press N it will go to choice but I can't input any letters because it will terminate
help.. me plz....

#include
#include
main()
{
int a,d,c,s,H,ls,car,SCIFI,ans;
char ch;
#define p printf
#define g gotoxy
#define c cprintf
choice:
{clrscr();
g(17,2);p(" >>()> JESSAR_AMA VIDEO RENTALS <()<< ");
g(25,3);p("CONTACT No.09092957632");
g(15,7);p("PRESS[");textcolor(WHITE+BLINK);c("A");p("]for ACTION:");
g(15,9);p("PRESS[");textcolor(WHITE+BLINK);c("D");p("]for DRAMA:");
g(15,11);p("PRESS[");textcolor(WHITE+BLINK);c("C");p("]for COMEDY");
g(15,13);p("PRESS[");textcolor(WHITE+BLINK);c("S");p("] for SUSPENSE:");
g(15,15);p("PRESS [");textcolor(WHITE+BLINK);c("L");p("] for LOVE STORY:");
g(15,17);p("PRESS [");textcolor(WHITE+BLINK);c("H");p("] for HORROR:");
g(15,19);p("PRESS [");textcolor(WHITE+BLINK);c("F");p("] for FICTION\n");
p("\n Enter your choice:_");gotoxy(33,21);
scanf("%c",& ch);}
switch(ch)
{
case 'A': clrscr();
g(29,1);textcolor(BLUE+BLINK);c("***************");
g(29,3);textcolor(BLUE+BLINK);c("***************");
g(43,2);textcolor(BLUE+BLINK);c("*");
g(29,2);textcolor(BLUE+BLINK);c("*");
g(30,2);textcolor(WHITE);c("ACTION MOVIES");
g(30,5);p("Are you sure?[Y/N]");
scanf("%s",&ans);
if (ans=='N')
{
goto choice;
}
break;

case 'D': clrscr();
g(29,1);textcolor(RED+BLINK);c("**************");
g(29,3);textcolor(RED+BLINK);c("**************");
g(42,2);textcolor(RED+BLINK);c("*");
g(29,2);textcolor(RED+BLINK);c("*");
g(30,2);textcolor(WHITE);c("DRAMA MOVIES");break;

case 'C': clrscr();
g(29,1);textcolor(YELLOW+BLINK);c("***************");
g(29,3);textcolor(YELLOW+BLINK);c("***************");
g(43,2);textcolor(YELLOW+BLINK);c("*");
g(29,2);textcolor(YELLOW+BLINK);c("*");
g(30,2);textcolor(WHITE);c("COMEDY MOVIES");break;

case 'S': clrscr();
g(29,1);textcolor(GREEN+BLINK);c("******************");
g(29,3);textcolor(GREEN+BLINK);c("******************");
g(45,2);textcolor(GREEN+BLINK);c("*");
g(29,2);textcolor(GREEN+BLINK);c("*");
g(30,2);textcolor(WHITE);c("SUSPENSE MOVIES");break;

case'L':clrscr();
g(29,1);textcolor(RED+BLINK);c("*******************");
g(29,3);textcolor(RED+BLINK);c("*******************");
g(47,2);textcolor(RED+BLINK);c("*");
g(29,2);textcolor(RED+BLINK);c("*");
g(30,2);textcolor(WHITE);c("LOVE STORY MOVIES");break;

case 'H': clrscr();
g(29,1);textcolor(YELLOW+BLINK);c("***************");
g(29,3);textcolor(YELLOW+BLINK);c("***************");
g(43,2);textcolor(YELLOW+BLINK);c("*");
g(29,2);textcolor(YELLOW+BLINK);c("*");
g(30,2);textcolor(WHITE);c("HORROR MOVIES");break;

case 'F': clrscr();
g(29,1);textcolor(GREEN+BLINK);c("****************");
g(29,3);textcolor(GREEN+BLINK);c("****************");
g(44,2);textcolor(GREEN+BLINK);c("*");
g(29,2);textcolor(GREEN+BLINK);c("*");
g(30,2);textcolor(WHITE);c("FICTION MOVIES");break;

default:gotoxy(17,40);textcolor(RED+BLINK);cprintf(" SORRY THE MOVIE TYPE YOU WANT IS NOT AVAILABLE!!!");
}

getch();}

I'm not sure what language this is, but why are you entering 'N', the menu should initiate right away and be waiting for your input.

Why do you have this line "int a,d,c,s,h,ls,car,scifi,ans;"? Why are these letters type of int? or is that a CONTINUATION of the program?If you want other people to help you, try to avoid this sort of thing:
Code: [Select]#define p printf
#define g gotoxy
#define c cprintf
If makes things hard to read and you can make a very bad error.

Aldo, it helps if you use a High-Level approach for something that is not going to be used to launch rockets .
Make a case block as clean and neat as you can. avoid details.
Something like this:

Code: [Select]case 'A' : dofirst;(); break;
case 'D' : dosecond(); break;
case 'E' : dothird(); break ;
case 'N' : goto choice;

Using inline code makes it hard to debug. Start out with void functions that are 'stubs', they don't do anything, but they are place holders where you will expand the code later as you work out the logic flaws. The concept is to HIDE details the are not relevant to the logic of what you are doing.
This way you separate the logic from the decoration.

2234.

Solve : how to copy entire Visual C# solution??

Answer»

Is there any way to copy an entire VISUAL C# solution in such a way that it works? If you just copy it and rename it, it gives an error message that it's been renamed and therefore it refuses to work.

Here's exactly what I did that isn't working:

I copied the folder, with all its contents, for the entire solution. This folder contains the .sln & .suo files and the project folder. Such folders are subfolders of C:\Documents and Settings\Bob Lewiston\My Documents\Visual Studio 2008\Projects. The copy of the solution folder is GIVEN a new name and also placed in C:\Documents and Settings\Bob Lewiston\My Documents\Visual Studio 2008\Projects. When I try to open this solution in Visual C#, I GET the error message I mentioned above.

Someone ELSE told me that they did the same thing I did, and it worked WITHOUT a problem for them. If that's so, could the problem be that my software is in some way configured differently than their's?

2235.

Solve : Vba6.Dll Issue in Visual Basic 6!!!?

Answer»

Hi everyone!, I'm working with my application code developed in Visual Basic 6, and SOMETIMES the visual basic application fails while I EXECUTE in debbug mode, and REFERS the next DLL:

Vba6.Dll

If you know how to solve this issue related with the dll, please HELP me!!!

Regards

2236.

Solve : SendKeys VB .NET?

Answer»

In .NET I can't get caps LOCK, scroll lock, num lock to WORK. I looked AROUND the web and found a lot of people have this PROBLEM but all the different solutions CONFUSED me. Anyone know how to make it work?According to VS 2003 helpfiles you use

Code: [Select]Sendkeys.Send("{CAPSLOCK}")
Sendkeys.Send("{NUMLOCK}")
Sendkeys.Send("{SCROLLLOCK}")
Work for you?

2237.

Solve : collating records from different SQL Server tables?

Answer»

I'm starting to learn SQL Server. As part of that effort, I'm experimenting with accessing AdventureWorks sample databases.

In database AdventureWorks, I've been accessing table Person.Contact. Although in that table there are columns for a phone number and an EMAIL address, there are no columns for a postal address. I see columns for a postal address in table Person.Address, but in that table there is no column for a numerical value ContactID, or for a string value for the contact's name, as there is in table Person.Contact.

It SEEMS to me, especially because each of these two tables' names start with "Person.", that these tables are somehow linked. However, I don't see any columns in either table which seem to allude to any other tables. For what it's worth THOUGH, each of the two tables has a column called "rowguid", the purpose of which I don't understand.

I'd like my app to display in a WinForm all the information available for each contact, but I don't know how to locate the Person.Address record corresponding to a given Person.Contact record. Can anybody TELL me how to do this?

2238.

Solve : delphi login code?

Answer»

I am just new in delphi and i had a hard time in USING it. One of my problem is the LOGIN form which has 3 users of different privileges. The code I have has plenty of ERRORS and I can't STILL pinpoint the correct code for it. I hope you could check it and give me some FEEDBACK about it.

Below is the my code:

procedure Tform_login.Button1Click(Sender: TObject);
var
form:Tform_studhome;
form:Tform_phyhome;
form:Tform_homestaff;
username, password, privelege :String;

begin
zquery1.SQL.Clear;
zquery1.SQL.Add ('select username, password from account where username= '''+edit1.Text+'''');
zquery1.Active := true;
username := zquery1.Fields[1].AsString;
password := zquery1.Fields[2].AsString;

if ((username = edit1.Text) and (password = edit2.Text))
then begin
ShowMessage('Login Successful!');
zquery1.Active :=True;
zquery1.SQL.Add('select privelege, user_idno from account where username = '''+edit1.Text+'''');
privelege := zquery1.Fields[3].AsString;

if(privelege = 'student')
then begin
form:=Tform_studhome.Create(self);
form.Show;
close;
end

else
if(privelege = 'physician')
then begin
form:=Tform_phyhome.Create(self);
form.Show;
close;
end

else
if(privelege = 'staff')
then begin
form:=Tform_homestaff.Create(self);
form.Show;
close;
end

end;

end;



Thanks and more power.

2239.

Solve : (VB) Call Form1_Paint after Form1_Load has been called.?

Answer»

I think the title is self-explanatory, but here's some extra:

What I am trying to do is so that whenever the end of Form1_Click is reached, Form1_Paint is called.
Code: [SELECT]Form1_Paint(sender,E)Returns error: Unable to cast object of type 'System.EventArgs' to type 'System.Windows.Forms.PaintEventArgs'.
Which is what I anticipated.

If I put this:
Code: [Select] Dim p As System.Windows.Forms.PaintEventArgs
Form1_Paint(Me, p)I am given the warning that 'p' is used before defined (It never IS defined) and later on, when trying to draw a rectangle in form1_paint: Object reference not set to an instance of an object.

So how do I either define 'p' or call form1_paint without causing error later on?

Here is my whole code (Not that long, not that complicated, promise :: the three lines of '' 's is where the errors occur):

Code: [Select]Public CLASS Form1
Public elist As New List(Of Point)
Public TXT As Integer
Public dot As Image = Image.FromFile(Application.StartupPath & "\data\dot.png")

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Form1_Click(sender, e)
End Sub

Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
elist.Add(New Point(Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y))
elist.Add(New Point(Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y))
''
''HERE IS WHERE FORM1_PAINT IS CALLED
''
End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
If Not elist.Count = 0 Then
For Each point In elist
Dim rect As Rectangle = New Rectangle(point.X - 5, point.Y - 5, 10, 10)
e.Graphics.DrawRectangle(Pens.Orange, rect)
''
'' THe above line is where an error is caught when using "form1_paint(me, p)"
''
Next
End If
End Sub
End Class
Mother f....

I hate google.

Hate it.

Yahoo FTW.

The first 30 minutes of googling, no success.

Two minutes after posting, i learn 'Invalidate()'

Calls all the *_paint functions as soon as your GPU can handle it. and my ATI Radeon 3200 can draw a box almost instantly.

*sigh*

Remove the thread, admin. Or leave this for other morons like myself.

*sigh*

2240.

Solve : VB6 File Browser?

Answer»

Hi im in the process of programming my DTR or payroll system..
I dn't know how to create file browser to import my txt files.. I just want the folder directory and txt file NAME...
As I read from other thread they suggest to use OPen dialog controls..
But when I ctrl J no such methods or class...

Can anyone give some hint? Do I have to change any settings in VB6?i usuallly use this API to do it:

Code: [Select]Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
ok i will try that one..
You use ms access 2003 then vb6?Quote from: KennMobelhaus on March 26, 2009, 09:47:16 PM

You use ms access 2003 then vb6?

i dont understand

but if you are asking about if the api will work on vb6 and will it also work on vba(access2003), then the answer is yes.
if you are asking me do i learn access first, then vb6, then the answer is again yes.VBA(msaccess03) that wats i mean heheh sorry for that....SO... i can use listbox or combo box to FIND the directory.. LIKE c:\data\data.txt
In short I want to use this: c:\data\data.txt as an input to my txtbox to import that text file...
If you dnt get wat i mean just tell me...the above win32 api is to show the windows open dialog.
example: open notepad, then press CTRL-O, it popup the open dialog window <--- vb6 will open this kind of window
is this what you want??

or are you looking to populate a listbox with the contents of data.txt???I would like to obtain the path and place as a value in a txtbox in order to import it..

example: c:\data\data.txt <----- this path by clicking onlyThanks for your time... I find it already in access library using Application.FileDialog(msoFileDialogFilePicker).


I appreaciate your time... thanks a LOT...Option Compare Database

Private Sub Command0_Click()

Dim fd As FileDialog

Set fd = Application.FileDialog(msoFileDialogFilePicker)

Dim vrtSelectedItem As Variant


With fd

.Filters.clear
.Filters.Add "All files", "*.*"
.Filters.Add "Images", "*.gif; *.jpg; *.jpeg", 1
If .Show = -1 Then

For Each vrtSelectedItem In .SelectedItems

MsgBox "Path name: " & vrtSelectedItem

Next vrtSelectedItem
Else
End If
End With

Set fd = Nothing


End Sub


Thats the code and I check some references... like Microsoft Office 11.0 Object Librarythat's great. glad to see it working now.

and sharing your code here is good, you'll never know if someone else with the same problem might need it in the future, and your code have provide some guidance for them.

but i have a question:
will the program work for computer without ms.office installed??
or if you have to pack it with the setup file, is it going to make the size bigger?i think its not so big... maybe a bit
2241.

Solve : Delphi problem...?

Answer»

I have a function to get BIOS information, for exapmple BIOS serial number as String. I USE this solution (found it in internet) :

Code: [Select]function SerialNumber: string;
const
sQuery = 'select SerialNumber from Win32_BIOS';
var
Item: SWbemObject;
NumProp: LongWord;
ObjectSet: ISWbemObjectSet;
OleProperty: OleVariant;
begin
ObjectSet := CoSWbemLocator.Create.ConnectServer( '', 'root\cimv2', '', '', '', '', 0, nil ).ExecQuery( sQuery, 'WQL', wbemFlagBidirectional, nil );
if Succeeded( ( ObjectSet._NewEnum as IEnumVariant ).Next( 1, OleProperty, NumProp ) ) and ( NumProp > 0 ) and Succeeded( IDispatch( OleProperty ).QueryInterface( SWBemObject, Item ) ) then begin
Result := Item.GetObjectText_(0);
end
else begin
Result := '<Unknown>';
end;
end;
So, it works unless I terminate the application. Then I get an "access violation" message. I deciced to use another code :

Code: [Select]BIOSSerialNumber := string(PCHAR(Ptr($FEC71)));

Then "access violation" COMES at the beginning before Application.Run

My problem appears only in Windows 2000. For the first code I'm pretty SURE the problem is with ExecQuery() function, but I don't know how to fix it...

2242.

Solve : How to make a new wireless connection to connect to the old one?

Answer»

Ok I'm on my IPOD
My two connections in "control PANEL. Network connections" went missing and now I can't connect to the NET so I wanna know how to recover my old connections or create a NEW connection to the old one
Thanks in advanced for any help

2243.

Solve : Passing value from a text box to a C program?

Answer»

hello there,
I WOULD like to DESIGN a C program that would take a string input from a text box designed in VBScript.
The task of VBScript code would be to call a C program and pass a string variable.
Is it possible?
please help.
Thank youQuote from: TRIPTI on MARCH 24, 2009, 11:43:25 PM

The task of VBScript code would be to call a C program and pass a string variable.
Is it possible?
yes see below

Code: [Select]s=inputbox("Enter argument for c program")
wsh.echo s
createobject("wscript.shell").run ".\ProgramC.exe " & s,1,false
2244.

Solve : SQL Server connection problem?

Answer»

I’m trying to learn how to connect to an SQL Server database (I’m using the AdventureWorks sample database), but I’m having problems.

Here’s the code I’m using:
Code: [Select]// define connection string for database server
string connectionString = "server=<server name>; database=AdventureWorks; uid=<user name>; pwd=;"; // no password

// define SqlConnection connection to database using connection string
SqlConnection conn = null;
try
{
conn = new SqlConnection (connectionString);
}
catch (Exception EXC)
{
MessageBox.Show (exc.Message, "conn = new SqlConnection (connectionString);");
}

// define SqlCommand command or command string that CONTAINS query
string commandString = "SELECT * from <table name>";

// define SqlDataAdapter data adapter using command string & connection object:
SqlDataAdapter dataAdapter = new SqlDataAdapter (commandString, conn);

// create new DataSet object (create DataSet)
DataSet ds = new DataSet ();

try
{ // fill dataset object with query result via data adapter (for SELECT)
dataAdapter.Fill (ds, "<table name>");
}
catch (Exception exc)
{
MessageBox.Show (exc.Message, "dataAdapter.Fill (ds, \"<table name>\");");
}

// result of query now stored in dataset object in table "<table name>"
// get reference to table by using indexer property of dataset object's Tables collection
dataTable = ds.Tables ["<table name>"];At the statement
Code: [Select]dataAdapter.Fill (ds, "<table name>");
I'm getting the FOLLOWING error: "Login failed for user ''."

As near as I can make out, the database AdventureWorks that I see in SQL Server 2008 Management Studio and that I'm trying to access resides at either C:\Program Files\Microsoft SQL Server\100\Tools\Samples\AdventureWorks 2008 OLTP or
C:\Program Files\Microsoft SQL Server\100\Tools\Samples\AdventureWorks OLTP.
I thought that maybe the problem was I was supposed to specify the full path name in the connection string, but that didn't help. Any suggestions?

NOWHERE do I see a provider name (should probably be SQLNCLI10). The providers are the low level component instructions from MDAC which are needed to do the actual I/O into the database.

Check out this page for more assistance.

Good luck.

2245.

Solve : Access database/storing values?

Answer»

Is there a way to store a displayed VALUE in a field that is the result of a calculation?

Thanks for any help offerred.Sure, define the table field and after the calculation, set the field value to the result.

It is not recommended you do this however. Better to recalculate the result on demand or use SQL to calculate the field to be used when needed.

Why is it necessary to store calculated fields in your database?

I'll try to explain this as BRIEFLY as I can.

This a database that, among other things, tracks children participating in a social service program. The children's birth dates are stored when those dates are known. SOMETIMES a staff member only has the age of the child and needs to estimate what the birth DATE might be.

On the Child Intake form, I created a pop up form that opens when staff clicks on a command button called "Estimated DOB Calculator." There are 3 fields on this form one of which is HIDDEN.

1. Start Date (This is the hidden field and defaults to today's date)
2. Staff enters the age in a field called "Child Age" (Referred to as "Text0" in the expression in #3.)
3. "FutureDate" is a field containing this expression (=DateSerial(Year([StartDate])-[Text0],Month([StartDate]),Day([StartDate])) This gives them the approximate DOB of the child.

Staff takes the results from field #3 and types it into a field on the intake form called "EstimatedDOB." Those are the values that are stored in the table. (Staff could do this in their heads but that's another story...)

I'm trying to figure out how to this calculation on the Child Intake form rather than the pop up and have the results from "FutureDate" transferred to the "EstimatedDOB" field in some way other than by having staff type it in.
1. put the "Text0" on ChildIntakeForm as unbound
2. create event "On Change" of Text0, and write the VBA code to:
- calculate the estimated DOB = date-age
- set childintakeform.estimateddob.value = calculated value above

2246.

Solve : How to invoke a batch file in C???

Answer»

I know, i know....USING the system function in C...but it just doesnt work 4 me...
Maybe someone can tell me what i'm doing wrong..

My c-program and my batch file are in the same folder...the name of my batch file is "openrob"...and if i run it from command prompt, it works..this is the simple code i wrote:

#INCLUDE
#include

void main()
{
clrscr();
printf("will call the batch file\n");
system("openrob");
getch();
}

I TRIED it putting the batch file in a separate drive altogther and specifying the path instead....still doesnt work...and yeah..my batch file doesnt take any arguments...

i also followed the same procedure...created a new batch file and TYPED out the same c-file as given in this link...

http://www.gidforums.com/t-5099.html

that didnt work either...is there a problem with my system or am i doing something fundamentally wrong??

Any suggestions...Ah, the famous "doesn't work" problem...

what error messages do you get?
Well...thats the thing...no error msg...!!!!!!

it executes all statements before the call..n all the statements after the call...and when i trace it out...it shows that it's EXECUTING the system() statement too...but nothing happens!!

There's no problem with the batch file though...coz i've checked it a hundred times from all possible locations and it works!Code: [Select]system("openrob");

try"

Code: [Select]system("openrob.bat");
what are you actually doing in your batch file. if its possible, do everything with C. Is it a constrain that you must use C ? because if you are doing system administrative work, C is not the "appropriate" tool for the job. I am having the same problem using Java with the same results.openrob.bat also doesnt work...

it's a system quirk i guess...coz the same thing is working in one of my frnz system..!!!!

2247.

Solve : void functions for soccer match?

Answer»

hi
i have this program but cannot find problem.
it suppose to enter the points of a SOCCER team & where they PLAYED.then it MUST CALCULATE the total points of the games played at home by the team & the points of the opponents.As well as the points played away from home by team & opponents.but it only reads in the last entry.
i think my void functions is wrong bt dnt KNW wat to change it to!!!
please help!!! please
//assignment 2 Question 5
#include
using namespace std;
int nr_matches = 9;


void inputAndValidated (int & pointsForp,int & pointsAgainstp, char & wherep)
{

for(int i=0; i< 4; i++)
{
do
{
cout<<"Where was the match played? ";
cin>> wherep;
cout< }while((wherep != 'H' ) &&(wherep != 'A'));

cout<<"Enter the number of points scored by the Lions : ";
cin>> pointsForp;
cout<<"Enter the number of points scored by the opponents: ";
cin>> pointsAgainstp;

}
}
void updateTotalsHome (int teamsPoint,int opponentsPoints, int & teamsTotal ,int & opponentsTotal)
{
teamsTotal= 0;
opponentsTotal=0;
teamsTotal += teamsPoint;
opponentsTotal += opponentsPoints;


}

void updateTotalAway(int teamsPointA,int opponentsPointsA,int & teamsTotalA ,int & opponentsTotalA)
{
teamsTotalA=0;
opponentsTotalA=0;
teamsTotalA += teamsPointA;
opponentsTotalA += opponentsPointsA;



int main()
{
int pointsFor,pointsAgainst;
int totalForHome,totalAgainstHome,totalForAway,totalAgainstAway;
int nrHome,nrAway;
char where;
// initialise totals
totalForHome=0;
totalAgainstHome=0;
totalForAway= 0;
totalAgainstAway=0;
nrHome=0;
nrAway=0;

inputAndValidated(pointsFor,pointsAgainst,where);


if(where =='H')
{
nrHome++;
updateTotalsHome(pointsFor,pointsAgainst, totalForHome,totalAgainstHome);
}
else
{
nrAway++;
updateTotalAway(pointsFor,pointsAgainst,totalForAway,totalAgainstAway);
}
cout<<"The total at this point is: "< cout<<"Played at home: "< cout<<"Total points scored by the team "< cout<<"Total points scored by the opponents "< cout< cout<<"Played away from home: "< cout<<"Total points scored by the team "< cout<<"Total points scored by the opponents "<
cout<
return 0 ;
}

2248.

Solve : BASIC for web programming??

Answer»

Quote from: BC_Programmer on March 18, 2009, 01:09:24 PM


PHP cannot be a programming language, since it is interpreted by the SERVER at run-time.
PHP, like Python or Perl, can be used to run PHP scripts, not necessary in a web environment. PHP provides basic programming constructs, data TYPES such as ARRAYS, loops, FLOW control MUCH like any others. therefore its also a programming language.
Code: [Select]# php5 -r 'echo "hello world\n";'
hello world

Quote from: ghostdog74 on March 18, 2009, 05:59:35 PM
PHP, like Python or Perl, can be used to run PHP scripts, not necessary in a web environment. PHP provides basic programming constructs, data types such as arrays, loops, flow control much like any others. therefore its also a programming language.
Code: [Select]# php5 -r 'echo "hello world\n";'
hello world



I know! I was being sarcastic, silly

if VBScript wasn't a programming language, as some here claim, then PHP couldn't be either Quote from: BC_Programmer on March 19, 2009, 08:51:27 AM
I know! I was being sarcastic, silly
oh...i see.
2249.

Solve : System Format Exception in debug VB 2008?

Answer»

Happy Thursday all.) Tour here again with a question regarding VB 2008

Ok if I am debugging an application in VB 2008 and in the immediate window I see
" a first chance exception of type System.FormatException blah blah blah" ( actually I have 3 of those lines)
Yet I am able to check my buttons without anything exploding on me,

Is there a way to find out WHERE the exception is in my code? And does first chance mean there is a possible System.Format Exception? and if so that would be I have 3 possible exceptions since I have that line APPEARING 3 times in my immediate window?

Obviously I am very new to VB so what may seem apparent to others its not very CLEAR to me(
Thank youIf you're running the program with debugging, when the error occurs it should take you to it. I'm using VS2008, maybe it's different for you.unless of course an On error resume next (or the .NET equivalent) is used...

does the application crash when you compile it?No it doesn't crash when I compile it.
When I click debug , the message in Immediate Window is
a first chance System.FormatException occurred in mscorlib.dll

It does not take me to error( I know what you mean though as when I have had errors in the past it always took me to the error)

My first question is still..does this mean there is a potential error but the application will still run?
Because I can still run my application. However.. I still have something wrong in my code as my Call event isnt correct.... hehe which is most likely where I am getting the SystemFormat but again it does not take me to that line of code. I am just assuming that is where the error is. ( yay go newb programmer)



I think I am supposed to be using Debug.WriteLine to help with debugging I am going to reread this chapter and then I will check back)
TourJust a note
I bring this question here as every time I ask my professor I get awesome one liners like:

" code doesn't work"


Which is sooo helpful, and I don't want to get kicked from class by saying. " No *@)! Sherlock why do you think I am asking for help?"

can you single step through and see when the errors appear in the immediate window? Sounds to me like some non-fatal exception that mscorlib is dealing with.

Which brings us back to your event! chances are the exception is thrown when the framework tries to raise your event and fails a few times before FINDING a way to call it properly?

debug.writeline if placed throughout your code can identify where the problem is it will appear between lines of debug output).I am getting closer, think I figured out where the error was.
Now I am stuck again on NESTED Try catch) Mayhap I should read your response to my question from a couple WEEKS ago.
=)
tour

2250.

Solve : VB starter?

Answer»

Hello

I'm a starter in VB

when I write a VBS file, can I use the same visual basic codes?

can VBS files do the same work that EXEs do?

thanksQuote from: feras on March 20, 2009, 04:30:52 AM


when I write a VBS file, can I use the same visual basic codes?
not really. download the manual for more info

Quote
can VBS files do the same work that EXEs do?

thanks
yes and no.No. VB Script and Visual Basic are not same.

Visual Basic is used to DESIGN windows applications.

VBScript uses the Visual Basic syntax. But it is a scripting language developed for scripting in HTML pages.


There is different like Java and JavaScript.thank you M.r ghostdog74
thank you M.r CBSk

what is the best version in visual basic and from where can I install it?

I downloaded VB from microsoft, but it requests to be online while intalling on PC

thanks Well you can BUY old VB6 or you COULD get the FREE version of VB.NET 03,05, or 08