PowerUsers.info - Paul Doherty Askme Archive of Questions and Answers

Return to AskMe Archive Main Page

Return to Main PowerUsers.info Main Page

**********************************************************************

Category : Visual Basic


QAId : 1315904
Asker : eQA
Subject : Enhancements in VB
Private : No

Question : Hi,

Could just tell what are the major difference between VB 4.0, VB 5.0 and VB 6.0, I am learning VB 6.0 now. And where can i get these informatiom.

Thanks,
Senthil.


Answer : I would say the biggest differences in these versions are in the:

1) IDE - the environment changed radically between 4 and 5 - the newer "Visual Studio" metaphor being in 5 and 6.

2) Internet ap development and database access. It has been improved in each version from 4 through 6.

Paul Doherty, CNA, CNE, MCP+I, MCSE, B.A.
http://members.home.net/iqueue


Rating : 4


----------------------------------------------------------------------
QAId : 1329078
Asker : REB41
Subject : Command Line parameter
Private : No

Question : How do I pass in a command line parameter into a visual basic exe?

Answer : In the VB app you will use the "Command" function to retrieve (if any) the command-line parameters the user typed. Here is the MSDN example:

Function GetCommandLine(Optional MaxArgs)
'Declare variables.
Dim C, CmdLine, CmdLnLen, InArg, I, NumArgs
'See if MaxArgs was provided.
If IsMissing(MaxArgs) Then MaxArgs = 10
'Make array of the correct size.
ReDim ArgArray(MaxArgs)
NumArgs = 0: InArg = False
'Get command line arguments.
CmdLine = Command()
CmdLnLen = Len(CmdLine)
'Go thru command line one character
'at a time.
For I = 1 To CmdLnLen
C = Mid(CmdLine, I, 1)
'Test for space or tab.
If (C <> " " And C <> vbTab) Then
'Neither space nor tab.
'Test if already in argument.
If Not InArg Then
'New argument begins.
'Test for too many arguments.
If NumArgs = MaxArgs Then Exit For
NumArgs = NumArgs + 1
InArg = True
End If
'Concatenate character to current argument.
ArgArray(NumArgs) = ArgArray(NumArgs) & C
Else
'Found a space or tab.
'Set InArg flag to False.
InArg = False
End If
Next I
'Resize array just enough to hold arguments.
ReDim Preserve ArgArray(NumArgs)
'Return Array in Function name.
GetCommandLine = ArgArray()
End Function

Paul Doherty, CNA, CNE, MCP+I, MCSE, B.A.
http://members.home.net/iqueue

Answer : That indenting got butchered... :-(

Look up the "Command" function in MSDN (or withing VB just type "Command()" and put the cursor inside it and press F1 for the same example.

Paul Doherty, CNA, CNE, MCP+I, MCSE, B.A.
http://members.home.net/iqueue




----------------------------------------------------------------------
QAId : 1353262
Asker : Anonymous
Subject : Installing Visual Basic
Private : Yes

Question : Hello !

I tried to install Visual Basic and first I must install Internet Explorer coming inside the Visual Basic CD. But I could not install it because I received the messages " Check if the Clock System is at the right time " and after clicking Ok " the Internet may be busy ".

I verified that the Clock System is at the right time but I received again the same messages.

Please what can I do for installing correctly Internet Explorer/Visual Basic?

Thanks !

Answer : I haven't heard of or seen this error. One thing you might try though is to install IE not from the CD, but from the MS Windows Update site:

http://windowsupdate.microsoft.com/

Click on "Product Updates" and it will show you a list of software that can be added - scroll down a bit and you will see "Internet Explorer 5.01 and Tools" or something similar. Check that one and install away. After that finishes you can run the VB install likely with no problems.

Paul Doherty, CNA, CNE, MCP+I, MCSE, B.A.
http://members.home.net/iqueue


----------------------------------------------------------------------
QAId : 1768246
Asker : morrkope
Subject : learning vb
Private : Yes

Question : I am a high school teacher and want to learn visual basic. I'd like to get a Learning edition of VB perhaps with a CD and manual. Can you direct me to a publisher or distributor that offers teacher discout prices?

Best wishes

Morry

Answer : Have you checked the local college bookstores? They often sell software at student discounts. I've never heard of a teacher discount for VB (and searches came up empty) but it may exist.

Paul Doherty, CNA, CNE, MCP+I, MCSE, B.A.
http://members.home.net/iqueue
Rating : 4


----------------------------------------------------------------------
QAId : 2191898
Asker : niceroy
Subject : game question
Private : No

Question : Do I make Tomb Raider with VB?

Answer : I have a newsflash for you - TombRaider's already been made. ;-)

VB wouldn't be the best tool for this type of real-time game as it's not the fastest code (it's also far from the slowest, however) and has fewer libraries for this sort of thing than, say, C++.

--
Paul Doherty, CNA, CNE, MCP+I, MCSE, A.A., B.A.
http://members.home.net/iqueue
Home of PC DiskMaster and other Windows utilities

Rating : 3


----------------------------------------------------------------------
QAId : 3048321
Asker : Anonymous
Subject : writing programs
Private : Yes

Question : I am curious about the feasibility of writing a program. The program I am thinking of would be something similiar to a macro used in excel where it would be windows based program instead. What I would want would be a program that I could start and then record a serious of mouse clicks and keyboard strokes and then play it back to automate mundane tasks in various different windows based programs. Any thoughts on the ability and difficulty of writing such a programs?
thanks!

Answer : Unless you are writing it for the educational benefit apps like this exist already. here's on to try:

http://download.cnet.com/downloads/0-10106-100-885106.html?tag=st.dl.10001_103_1.lst.td_885106

As for writing it I have written some things similar to this (try PopKey off my download page) and it is some work. I would suggest you take a look at WinBatch, a compilable scripting language that I used to write PopKey. It's very powerful and useful.

http://www.windowware.com

The interpreted version is free; the compiler costs.

--
Paul Doherty, CNA, CNE, MCP+I, MCSE, A.A.Sc., B.A.
http://members.home.net/iqueue
Home of PC DiskMaster and other Windows utilities



----------------------------------------------------------------------
QAId : 4386435
Asker : Anonymous
Subject : 6.0
Private : No

Question : In Visual Basic 6.0, I am running a calculation program (with many loops and for nexts) in which I want to allow the user to interrupt it. Therefore, I need to be able to check when the user presses certain keys.

What command do I use to check when the user presses a key? This is not associated with any object event (i.e. - Text1_KEyPress), but it is totally separate.

Answer : Here is material on this subject from the book "Using Visual Basic 6.0" chapter 15:

"Using the KeyPreview Property

Sometimes you want a form to process keyboard input, even if a control on a form has the focus. You use the form's KeyPreview property to do this.

When you create a form, the default value of the KeyPreview property is False. Thus, any keyboard input that you send to a control on the form (a TextBox, for instance) goes directly to that control. If you set the value of KeyPreview property to True, however, the form intercepts all keyboard input. You can then access the input through the form's keyboard event procedures. After the form handles the input, it's passed to the control with the focus.

At http://www.mcp.com/info is a sample project, KeyPress.vbp, in which the form's KeyPress event procedure intercepts all keyboard input headed for a TextBox and manipulates it into a backward string, and then ASCII reads it out (see Figure 15.4). It then sends each respective string to its own TextBox control. The form can intercept and distribute all the keyboard input to the various TextBoxes because the value of the KeyPreview property is set to True. Listing 15.3 shows the code for the Form_KeyPress() event procedure."

--
Paul Doherty
http://members.home.net/iqueue




----------------------------------------------------------------------
QAId : 4395202
Asker : heavytrack
Subject : check open status
Private : No

Question : How do I check to see if an application is already open so I don't have an error when I try to open it? Specificaly Microsoft Outlook.

Thanks

Answer : Perhaps you can use the function AppActivate and use it's success or failure as an indication of the presence of the application?

ex.

AppActivate "Notepad - (Untitled)"

--
Paul Doherty
http://members.home.net/iqueue

FUQuestion : AppActivate "Notepad - (Untitled)" causes an error if it is already open. How can I handle the error to make my code do something rather than terminate and then see the pop-up box say that there was an error?




Answer : Can't you trap the error with an error-handler, and use the error as a "success" code to determine that the app is not running?

Something like this - run the program a few times with known fake app names that will not be in existence and in the error-handler section use MsgBox commands to echo out the Err.Number so you'll know which to set the case below to check for - then run it a few times for apps you know *will* be in existence (open a Notepad for example and run the code with Notepad still running):

(towards the top of your section that will test for the existence of the app)

On Error GoTo AppError

(REST OF CODE GOES HERE, INCLUDING AppActivate COMMAND THAT WILL GENERATE AN ERROR)

AppError:
Select Case Err.Number
Case 67 ' Pretend this is the one that we know is when the app doesn't exist
(Do whatever we like now that we know it doesn't exist - setting a flag here is a good idea so when we issue our "Resume Next" we can check to see whether the app existed or not)
AppNotExist = True
Resume Next
Case Else ' some other error occurred
(deal with error)
Resume Next
End Select
EndAppError:


AppActivate may not end up being the best way to detect apps other than your own that are running, but I think with the above you can easily make this work. To detect additional instances of your *own* app is easy:

Private Sub Form_Load()
If App.PrevInstance Then Exit
End Sub

This may also help:

strTitle = "Whatever"

' Get handle to previous instance
lngHandle = FindWindow("App I'm Looking For", strTitle)


Also see this demo for some other related info:

http://www.mvps.org/vbvision/Sample_Projects.htm#App_Activate_Demo

--
Paul Doherty
http://members.home.net/iqueue

Rating : 5


----------------------------------------------------------------------
QAId : 4451702
Asker : cbachman
Subject : Creating VB Program
Private : No

Question : Hi Paul,
I have a basic understanding of visual basic 6,
and would like to create my first program,
can give me an overview of how I should do this,
I was going to use the wizard but didn't know if
this is how the pro's do it, Thanks for your help,
Chris

Need More Information : What kind of program are you making?

The wizard can be useful since it can take a lot of the cumbersome tasks out like menu creation, splash screens and the like, but it's probably a good idea to try these things yourself once so you know what to expect.

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities

FUQuestion : Hi
It is a program that is currently written
in exel, and is pushing the boundries so to speak,I
think the program is complex enough now to warrent moving it to a "real" programming language like vb. Most of it is user entry,calculations, and alot
of if statements. I know the wizard is useful but as you said , I would like to create the program by hand to understand is happening, I have a few books and puchased the vb 6 learning edition, but they don't really show how to create all the things a pofessional program should have, Would you recommend
any books,etc?, Thanks

Answer : I would just make a practice version of the app (get in there and draw a basic interface and put come code behind it) with at least a few of the major functions you'll need in the end. That way you'll get a feel for event-driven design and get familiar with the syntax.

As for books I don't know your familiarity with VB or with other languages but here is a good one:

http://www.amazon.com/exec/obidos/ASIN/0735605580/recommendevisual/107-8363311-7768535

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



End :
Rating : 4


----------------------------------------------------------------------
QAId : 5000588
Asker : T_runner
Subject : MSCOMM
Private : Yes

Question : I seem to have a problem, I need to open a com port and display the text comming across, So here it is:
Using MSComm I need to open com1
display all info comming across this port in a text box (text1)
Basicly I need to do what Hyper term does.
Can you help me? Please respond ASAP

Thank you verry much for your time
-Jim

Answer : Try this discussion:

http://www.devx.com/gethelp/newinquiry.asp?ItemID=16691


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 3


----------------------------------------------------------------------
QAId : 5293116
Asker : mysinghal
Subject : Keyboard Event
Private : No

Question : How can i disable/trap "Print Screen" button press.

Answer : Here are a couple of apps that can remap keys:

http://www.zdnet.com/pcmag/pctech/content/16/09/ut1609.001.html

http://www.microsoft.com/Windows95/downloads/contents/WUToys/W95KernelToy/Default.asp


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities


Rating : 4


----------------------------------------------------------------------
QAId : 5526316
Asker : allan_stapleton
Subject : windows
Private : No

Question : i have 1 Main form which opens up several
forms and i have to select cascade/tile from the menu

how do i arrange windows in a program
to cascade / tile ?

Please
and please include some example code
thanking you

Answer : Here is an example page:

http://amazon.informit.com/alphabooks/0789721198/ch07/ch07.shtml

Do a find on "vbCascade"

So within the main form after opeing the child windows you would do something like:

me.Arrange vbCascade

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 5531956
Asker : paccoro@...
Subject : visual basic
Private : No

Question : Hi Expert,
In a program I am checking to see if the user inputs something in a textbox named txtAns. I am using the following statement.
If IsNull(txtAns) Then
intRes = MsgBox("You haven't entered anything")
Else
intRes = MsgBox("Thanks")
End If
However when I run the program, even if I do not enter anything in the text box, the message reads "Thanks".
Where is the problem?

Answer : Try using the keypress or keydown events on the textbox object to determine if the user has input data. If those events fire you can set a global flag like "TextEntered=True" (having set it to "False" at program initialization) and be able to tell if the user has entered anything.


--
Paul Doherty, CNE, MCP+I, MCSE, CCSA, CCSE
http://members.home.net/iqueue
Home of PC DiskMaster and other Windows utilities


Rating : 4


----------------------------------------------------------------------
QAId : 5607267
Asker : tfy2
Subject : Add Control during runtime
Private : No

Question : Dear Expert,
how do i add a control during runtime ?

for instance, I want a form to contain x text box where x is the number of records of a table. And Each record in the table must be display on each text box.

Thanks

Answer : Use a control array and you can generate more during program execution.

http://msdn.microsoft.com/vbasic/technical/99pasttips.asp#10-11-99

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6183357
Asker : digsby14
Subject : Why asp and cgi?
Private : No

Question : I have only seen html forms handled by .asp files and .cgi files. Is there a reason that only these files can take the arguments sent to it and act on the form input. If I have an html file saved locally on my hard drive can I send a form to a visual basic program instead. Would this be so different then calling the program from the command line with arguments? In asp and cgi the data from the form comes in over the standard input. Is there a way to create a regular VB app that excepts arguments in the same way? If anyone has any insight, brainstorming, or solutions to this please flood me with replies. And if this isn't possible let me know that too (maybe with a little explanation as to why )
Thanks,

Answer : Yes you can. I myself have written CGI-BIN stuff in Perl - all you need is a language that can extract the query information from the HTML submit. Check into a module available called 'cgi32.bas' available on the web for functions that help.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 3


----------------------------------------------------------------------
QAId : 6286950
Asker : aserebry
Subject : Array of Strings
Private : No

Question : I have a dynamic arary of of strings (Dim BankName() as String)
How can I read values from this array of strings and populate combo box with the values from this array.

Thanks a lot!

Answer : I wrote a quick test app - just made a new project EXE, dropped a combo box on it and wrote this code:

Private Sub Form_Load()
Dim myarray() As String

' in this loop I can make the array as long as I want
For i = 1 To 100
ReDim Preserve myarray(i) As String
myarray(i) = i
Next

For i = 1 To 100
Combo1.AddItem (myarray(i))
Next
End Sub

With this you get the combo box with the drop-down filled with the numbers 1-10


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6304226
Asker : school1012
Subject : variable for property
Private : No

Question : How can you set a variable to be substituted for a property value, such as picture.cls, and use that variable in a sub to clear the picture box.

No matter how I dim the variable, I get an error stating "Compile error: Expected Sub, Function, or Property".

How can I dim a variable so it can be used as a property?

Any help appreciated. Thanks

Answer : I don't see a way to do that. What you can do instead is use the value of the variable you intend to be the property of the object as the variable in a switch/case type of statement:

dim s as string
s = "Text"

switch s

case "Visible"
' do whatever you need for Visible property here

case "Text"
MyObject.Text = "Stuff"

etc...


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6347672
Asker : tfy2
Subject : Windows NT application
Private : No

Question : Dear,
Is there any different for develop application for Windows NT and Windows 9x ?
what do i need to include in my VB program when coding for windows NT program ?
Thanks

Answer : Unless you're manipulating the system at some level (registry, system files, etc) you shouldn't have to do anything different.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6573895
Asker : gibran66
Subject : V.B
Private : No

Question : HI,
Can u pls tell me that
what exactly Loop does ? and what is the differnece between Do while Loop and While Wend
thank u in advance
pls reply sooon

Answer : A loop is a programming device that allows you to do a particular process more than one time, usually when you don't know for sure how many times you will need to process it (a "for" loop is usually used when you know before-hand how many times to loop).

A good use of a while loop is a control trigger to wait for a certain thing to be true before continuing with your program. For example let's say you want to get positive numeric input from the user, and want to be sure it's valid input. With a loop this can be done in a nice short (elegant) way:

done = FALSE

while done == FALSE

____Prompt user for input
____assign input to variable
____check to see if input is a number and is positive
____if it is, set done = TRUE

endwhile

Can you see that this loop will continue indefinitely until the user inputs a number that is positive?

The difference in a While/WEnd and a Do/While loop is that a Do/While loop will always have its contents run at least *once* since it's check for looping is at the END of the loop, while a While/WEnd type of loop checks before entering the loop and can possibly never have its contents run even once.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 2


----------------------------------------------------------------------
QAId : 6575003
Asker : jaljahmi
Subject : Batch processing and Dll
Private : No

Question : All,

I'm developing a system that will use VB dll's to batch process different jobs(input/output files).

Does anyone know of a client server batch scheduling system or way to have jobs executed automatically or by operators. I don't want to develope from scratch. I don't have the time right now.

Let me know if you know of any product out there or any suggestion on how to do this.

Jamal

Answer : All versions of Windows have this natively. In Windows 95/98 it's the "Windows Task Scheduler" (white icon in systray at the bottom-right - also add-able from Add/Remove Programs control panel, Windows Setup tab). In NT/2000/XP you will need to install the Scheduler service or just enable it and then use the 'at' command to schedule your jobs. If you need more info on how to use these tools continue this question and elaborate on what you need.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5

FUQuestion : Paul,

thanks for making me aware of "Windows Task Scheduler". I already found some good use for it.


What I'm looking for is a batch scheduling application that does the following:
- run job interactivly or on schedule
- Run job on other computers
- let an operator monitor jobs status

this would be used in a computer operation center to run and monitor jobs.

Jamal


Answer : Here are some schedulers:

http://dmoz.org/Computers/Software/Shareware/Windows/Utilities/Automation/
http://www.hallogram.com/crondsys/
http://softload.narod.ru/utilities/application_schedulers/

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities




----------------------------------------------------------------------
QAId : 6591043
Asker : kelvintoo
Subject : vb new learner
Private : Yes

Question : Being so many years of experience in programming language, do you have any advice for the people like me that first time learn the programming language - vb. What do you think the smartest way to learn it, what are the problems that normally a programmer will faced & how to solve or prevent it. Thanks....

Answer : VB is a great way to start (and continue). VB is unique in that it's quite well structured (unlike old style BASIC) and it is in wide use so you can easily get a job doing it after you get better.

I'd say the most important thing about learning to program is to be fully aware of the constructs available to you (iteration, branching, functions, etc). The more you know about these constructs the easier it will be to devise a solution to whatever problem you decide to tackle. Also this makes it easier to move to other languages.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5

FUQuestion : Normally if you develop a customized application / system for a company, what are the biggest problems normally you & customer will face & how are you going to solve it. Thanks....

Answer : I haven't done any large projects like that but I have heard one of the BIGGEST problems you are likely to encounter is:

scope creep - where the functions and features grow as the project progresses. This can set the delivery date back and make the whole project more costly. Being very specific about how and what is to be built is very important early on.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6597512
Asker : kelvintcg
Subject : vb
Private : Yes

Question : If i want to develop application that will integrate with microsoft sql database & commerce server( Like e-business intelligent), is it enough to learn visual basic & sql only or i need to learn other programming language as well . Thanks....

Answer : VB is an excellent language for accessing databases to my knowledge. Unless you know of a specific shortcoming of VB in this regard I'd think you would be well served by it.

Rating : 4


----------------------------------------------------------------------
QAId : 6599962
Asker : Paul_spencer85
Subject : does a file / object exist
Private : No

Question : Dear expert,
Is there any way to detect if an object exists without causing an error.

I am trying to build a VBA program that opens a workbook and writes some details away. for robustness I need it to be able to detect if the file exists, if not I will create a new file. at the moment I get the error '1004', which I believe happened also when I tried to reference an object that did not exist.

Thanx in advance

Paul

Answer : Have you tried setting an error handler and watching for that error code?

(near the top of the module that will test for the file's existence)

on error goto ErrHandler
(code goes here)


(bottom of code section)
ErrHandler:
Select Case Err.Number
Case 1004
(file doesn't exist so create it here, or set flag to FALSE for file existence)
RESUME (returns to line that errored) or RESUME NEXT (resturn to line immediately after erroring line)

Case xxxx
(any other individual cases you care to handle can be added)

Case Else
(handle general cases that don't fit your specific ones above)



--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities





Rating : 5


----------------------------------------------------------------------
QAId : 6609818
Asker : bumbazz
Subject : SendKeys
Private : No

Question : Hi all,
I have to solve an urgent problem: I must send the characters "ctrl" and "insert" from VB6 to an external application, to copy the previous selected text.

This is my code:

Set appAskSam = New AskSam.Application
appAskSam.Visible = True
appAskSam.Documents.Open Path appAskSam.ActiveDocument.Search StringToSearch appAskSam.ActiveDocument.StartOfDoc
appAskSam.ActiveDocument.EndOfDoc True

SendKeys "{^}" + "{INSERT}"

appAskSam.Quit 0
Set appAskSam = Nothing


With this instruction
appAskSam.ActiveDocument.EndOfDoc True
I select te text

and the line
SendKeys "{^}" + "{INSERT}"
doesn't work

appAskSam is my external application, askSam 4 Trial

What can I do?

Thanks in advance.

Answer : Try using the more standard CTRL-C for copy and CTRL-V for pasting. Here is a sample app I wrote that does some text entry and then copies and pastes part of the text:

Private Sub Form_Load()
ReturnValue = Shell("C:\Program Files\Windows NT\Accessories\wordpad.exe", 1)
AppActivate ReturnValue
SendKeys "Hi" & vbCrLf, True
SendKeys "Gr8" & vbCrLf, True
SendKeys "abcdefghijklmnopqrstuvwxyz", True
SendKeys "{HOME}", True
SendKeys "{INSERT}", True
SendKeys "My name is Paul", True
SendKeys "{HOME}", True
SendKeys "+" + "{END}", True
SendKeys "^" + "C", True
SendKeys "{END}", True
SendKeys "{ENTER}", True
SendKeys "^" + "V", True
End Sub

The "+" above is the SHIFT key.

The resulting text from running the above:

Hi

Gr8

My name is Paulpqrstuvwxyz
My name is Paulpqrstuvwxyz

which demonstrates that the INSERT worked, since I am overwriting the ABCs I typed, and the copy/paste worked since I have two copies of the last line.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

FUQuestion : Thanks Paul,
but with "^" + "C" it doesn't copy nothing to me.

Now the question is different:

appAskSam.ActiveDocument.Search SearchedString
Debug.Print SearchedString
appAskSam.ActiveDocument.StartOfDoc
appAskSam.ActiveDocument.EndOfDoc True
SendKeys "^" + "{INSERT}", True

these instruction are in a cicle and "SearchedString" is always different and present in the document;
as result I have 5 outputs (like the number of cycled), but only 3 of those are different. For example I have

a-c-c-e-e instead of a-b-c-d-e

I tryed with and without the true option.

Need More Information : I guess I'm not getting what you are trying to do. Can you show me the text of an example document and then what you're trying to achieve?

FUQuestion : Ok.
Imagine that you have 5 keys (a, b, c, d, e) and you have to search them in a database. This database is calle askSam and it's not normal, because it looks like a text editor where every page is a record and it doesn't recognize SQL commands.

My problem is retrieve the records and copy them in a word document.

These are my VB steps:
1. Open a new word document (done)
2. Open the askSam file where I'll search the keys (done)
3. Read the key from a text file (done)
4. Search the value in the askSam db (done)
5. Select the entire page (remember that it looks like a text editor) (done)
6. Copy the page
7. Paste it in Word
8. Return to the step 3 until EOF

In Word, instead of the entire record of a-b-c-d-e, I have (for example):

a-a-c-c-d
OR
b-b-e-e-d
or something else.

Thanks a lot.



Answer : Hmmm if your Word document ends up with:

a-a-c-c-d
OR
b-b-e-e-d

it would seem the problem lies either with your loop construct (unlikely) or with the format of the data you retrieve from the "database", no? The problem doesn't appear to be with your copy/paste operation or sendkeys since if they work for one they should work for all.


----------------------------------------------------------------------
QAId : 6651553
Asker : Anonymous
Subject : VB Program
Private : Yes

Question : Hello Expert Programmer:
how are you?
i heard that you ranked the highest in solving vb programs. i am having difficulty writing the follwing program, can u please help me develop the following program. i worked for hours to solve it, but couldn't develop this one. i will really appreciate your help. and thanks in advance.

A parking garage charges a $6.00 minimum fee to park for up to three hours. The garage charges an additional $1.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $25.00. Assume that no car parks for longer than 24 hours at a time. Write a program that will calculate and print the parking charges for each customer who parked his or her car in his garage yesterday. You should enter the hours parked for each customer. Your program should print the results in a neat tabular format and should calculate and print the total of yesterday's receipts . The program should use the procedure CalculateCharges to determine the charge for each customer.
thanks once again.

i have done lot of program prior to that, but this one is going over my head. this one seems like a advance VB program, and i am the beginner programmer. so, please do help me finish the program. thank you so much.....


Answer : I have done this up in pseudocode - I won't do your homework for you , but this should help a great deal.

fee = 0; total customer owes for parking

for i = 1 to numcarsparked
do
hours = i.hours ; get the number of hours the car was parked from each car
fee = fee + CalculateCharges(hours) ; invoke once for each car parked
done

CalculateCharges(int myhours)
myfee = 6 ; minimum charge is 6 dollars

if myhours <= 3 then
CalculateCharges = myfee ; if less than three hours parked then minimum fee applies
Return ; and we return to the calling subroutine with the value
endif

if myhours >= 16 then ; we charge max fee for 16 hours or more (6.00/3hr + 1.50/hr (13 hours is 19.50, 19.50 + 6.00 is 25.50)
CalculateCharges = 25 ; set max fee and return
Return
endif

myhours = roundup(myhours) ; use a function to round our numbers up to the next whole number (since the instructions say any hour or part thereof)
myhours = myhours - 3 ; remove our minimum hours since we've already charged for it with our $6 above
myfee = myfee + (myhours * 1.5) ; total up the fee
CalculateCharges = myfee ; return with fee
Return


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6687509
Asker : Anonymous
Subject : VB Question
Private : No

Question : Hello Sir:
i have difficulty understanding the following questions, can u please help me.
1. Identify and Correct the error(s) in the following questions:
a)Assume that the variable p is declared as Long.
For p = 1 <= 100
Print p * 1202
Next P

b)Dim taxRefund As Money

2. Write the Visual Basic code to accomplish the following questions:
a)Assuming that Option Explicit is activated, create a string variable called NL and assign a carriage return and a line feed to it.
b)Text1 and Text2 are Textboxes; add Text1 to Text2 and put the answer in Label1. (Hint: at least one TextBox must be a value.)

Answer : For p=1 to p <= 100
print p * 1202
next p

Dim taxRefund as Currency


2a)
Create a textbox called Text1 and set it's MultiLine property to True, then run this:

dim NL as String
NL = vbCr & vbLf
' also could use NL = vbCrLf
Text1.Text = "This is a message" & NL & "to see if CRLF works"

2b)
Create two textboxes and a label - use default names so they match mine.

Text1.Text = "This is a message to see if CRLF works" & vbCrLf
Text2.Text = "This is the Text2 text"
Label1.Caption = Text1.Text & Text2.Text

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities


Rating : 5


----------------------------------------------------------------------
QAId : 6754695
Asker : ant_jos2001
Subject : text box in v.b 6.0
Private : Yes

Question : can you please help me with this question in v.b:

i have a form, inside this form i have 3 text boxes text1, text2 and text3 and i have 1 command button command1.

Now what i want is, when i press the command button, the formula in it is: text3 = text1 + text2

when i put value 50 in text1 and 60 in text2 and the press command1, the result in text3 should be 110, it's not like that, because it takes two string variables and add them together, i know that there is a solution which is:

dim x as double
dim y as double

x = text1
y = text2

text3 = x + y

but this is not a good solution because maybe in 1 form i have 20 numeric fields, so how can i deal with them in better and direct way as numbers.

thank you.

Answer : You need to use a conversion function inline with your addition. The values in the text boxes are, unsurprisingly, text, and must be converted to numbers before they can be added.

text3.text = cdbl(text1.text) + cdbl(text2.text)

cdbl (Convert to Dbl) will convert the strings to dbl precision floating point numbers for addition. I didn't test this line above as I don't have VB installed right now, but it will be something along those lines.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 6763185
Asker : puneet83
Subject : app dist. & timing
Private : No

Question : Hello Expert !

I've got two questions to ask u ! ..

I'm a beginner to VB (but not to the world of
programming). I work on VB6.
I've read bout VB runtime files in MSDN.
However, I've seen a system running on Win98Se,
which already contains these files. (without any
VB app. installed on it). My earlier Win95 system
didn't have these files (quite obvious :).
So they say it's the best to distribute the
runtimes files along with the App, in the setup
package !.
However, if I know my target Windows Ver., this
necessity can be eliminated.
I wanna know which ver. onwards, Windows comes
packed with VB6 dlls. !?
Also, are these runtime dlls diff. for diff.
service packs, which can be installed on VB ?
I've VB6 with SP5.


another thing I wanna know is, how much my program
can count in a period of 1 sec.
have a look as this code

Dim count as long

count=0

Do
count = count + 1
Loop

Appearantly, this loop will run for ever.
However, I want something to interrupt this loop
after 1 sec. and display the value of count.
So I'll know how much can my program count in
1 sec.
How can something like this be accomplished !?

please help !

greetings,
Puneet.

Answer : I can't help you with which OS has which runtime files - I'd suggest you search support.microsoft.com for that, or just include the latest runtimes with your apps.

As for your timing code snippet:

Dim count as long
count = 0

mytime = timer
do while timer < mytime + 1
count = count + 1
loop

' now print a message with the value of count to see how high it got during the second.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 6778161
Asker : Anonymous
Subject : dataCombo box - VB
Private : Yes

Question : I am developing an application that uses a dataCombo box. A pull down list is populated using a database.
How do I go about clearing the DataCombo box,
ie. deleting the entire list?

Lou

Answer : Just use the "Clear" method of the combo box:

combo1.clear

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities


FUQuestion : Thanks, but that only works (as far as I can tell) on the combo box and I am using a dataCombo, which is different.
Declined (Reason) : Sorry, I don't have that information.


----------------------------------------------------------------------
QAId : 6784403
Asker : Anonymous
Subject : Pakage and Deployment Wizard
Private : Yes

Question : In Pakage and Deployment Wizard, there is option for Deploy . I don't understand what is it for?
I thought just use pakage option to pack it up and we will have a setup.exe file,I thought that's all we need.
Also. Can I package the .vbg file if I have a project group?
Thanks in advance!

Answer : This MSDN article fully discusses the P&D Wizard:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconcreatingsetupprogram.asp

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6787193
Asker : Anonymous
Subject : Visual Basic and OCX files
Private : Yes

Question : Hi Paul
When I downloaded some stuff from Planet Source Code, the downloads with Ocx Files would not open in Visual Basic 6(Pro Edition). I am geting an error telling me "The .ocx file could not be loaded". Why is this? How do I get these utiities to work?

Thank you

Answer : Copy the OCX file to \Windows\System then open a DOS prompt and type:

c:
cd \windows\system
regsvr32 myfile.ocx

This will register the OCX for use.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5

FUQuestion : Paul
Thank you, for your prompt reply, That did the trick. But it leaves me with a lot of other questions about OCX files and compiling programmes. To boil it down to one (big one).... Where would I find out more about OCX files, what they do and why and how and where would I write and use them ETC ETC.
Again thank very much.

Answer : Just open your favorite search engine and put in some terms like:

ocx activex

and you'll find more than you ever wanted to know... :-)

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6795981
Asker : gene_1951
Subject : Sending an email with attachment using VB
Private : No

Question : I would like to send a MS Outlook based email message with attachment using Visual Basic. Can anyone point me in the right direction or provide example code?

Answer : Here is a ton of help:

http://groups.google.com/groups?q=vb+send+email+outlook+attachment&hl=en
Rating : 5
End :


----------------------------------------------------------------------
QAId : 6804037
Asker : budwatkins
Subject : VB Certification
Private : Yes

Question : Hi, would you know of any VB certifications that are less involved than the MCSD (certifications that concentrate just on VB)?
Thanks
Bud

Answer : I don't know of one other than the MCSD (it is MS's language, after all). What you could do is just take and pass the two or so exams that directly relate to VB and use those on your resume.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 6826810
Asker : imadayoub
Subject : command button in v.b.
Private : Yes

Question : Hi,

Simple question in Visual Basic 6.0 concerning command buttons, the question is:

Is there any way to change the fore color of a command button to red on got focus event of the command named command0, I tried that, but I canít change the fore color of a command button, although in M.S Access it is very easy and can be done such as:

Private Sub Command0_GotFocus()
Command0.ForeColor = QBColor(4)
End Sub

So, can we do that in V.B 6.0 or is there any equivalent command to do that??

Best regards,

Answer : I don't think the standard button has properties for forecolor. I used the Sheridan 3D controls for my buttons - they support colors and bitmaps for their buttons.
Rating : 5


----------------------------------------------------------------------
QAId : 6863588
Asker : Anonymous
Subject : %1 symbol
Private : Yes

Question : Hi.
Do you know what %1 after an application file inside the regedit program mean?
I saw people talk about it somewhere and didn't pay attention and now I need to find out what it mean.

Thank you advance for your help.


Answer : It's a replacable variable used to invoke a program with a parameter at the end. For example if you drag and drop a text file onto a shortcut to Notepad Windows will invoke the notepad.exe with a space and the path and name of the file you dropped.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 6868676
Asker : kungkk77
Subject : how to set the width of the columns in the excel
Private : No

Question : hi, expert
i need to know that how to set the width of the columns in the excel using VB.

thank

Answer : Take from a conversation online:


Dim myExel as object

In a procedure you can reference Column D in your first worksheet like
this:


Set myExcel = GetObject(, "Excel.Application")
myExcel.activeworkbook.Worksheets(1).Columns("D:D").ColumnWidth = 18.43

If you wonder about HOW to do something With Excel, the solution is often
how you do it IN Excel. Record a Macro In Excel and record the changes you
wish your program to do. Then edit the macro to see wich syntax Excel uses
and that is usually code you can use from your VB-application.

Try it out!


Terje Viken



Bruce Feuchuk <**bfeuchuk@jumppoint.com> wrote in article
<33b5e8f3.23341554@news.jumppoint.com>...
> I've searched high and low.... tried many-a various attempts. And by the
> looks of things, you cannot adjust a Cell Width of a New XLS file (you can do
> alot of 'look up' only)... But no where can I find the info on HOW to set the
> Width of a given Cell column! Even the MS knowledge base gives nada to my
> many-a seeks!
>
> Anyone with the Knowhow able to advise? Mucho appreciated!
>
>
> Regards,
> Bruce
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> If you call me a 'gun nut' again I'll shoot you!!!
> (live from the West End of Vancouver, B.C. Canada)
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> NOTICE: Please remove the <**> from the begining of my Address before you
> ~~~~~~~ send me ANY Email replies. This was done to STOP all UnSolicted
> ~~~~~~~ JUNK E-Mailings. Such E-mailings is Not Welcomed nor Wanted!
>
Message 2 in thread
From: fred (zizi@enterprise.net)
Subject: Re: How to adjust Excel Column Width?
Newsgroups: comp.lang.basic.visual.misc
View this article only
Date: 1997/07/02


Here's a different method which adjusts the width of the range automatically
to fit the data in the cells....

obj_Spreadsheet.Range(*Top Left*, *Bottom Right*).autoformat Format:=3,
Number:=True, Font:=False, Alignment:=True, Border:=True, Pattern:=False,
Width:=True

Pete

In article <33b5e8f3.23341554@news.jumppoint.com>,
**bfeuchuk@jumppoint.com (Bruce Feuchuk) wrote:
>I've searched high and low.... tried many-a various attempts. And by the
>looks of things, you cannot adjust a Cell Width of a New XLS file (you can do
>alot of 'look up' only)... But no where can I find the info on HOW to set the
>Width of a given Cell column! Even the MS knowledge base gives nada to my
>many-a seeks!
>
>Anyone with the Knowhow able to advise? Mucho appreciated!
>
>
> Regards,
> Bruce


Rating : 5


----------------------------------------------------------------------
QAId : 6873323
Asker : limor
Subject : color pallete
Private : No

Question : hi,

how do I cerate a color pallete control -
for the client to choose a color?

thanks

Answer : Try the MB ColorPicker located here:

http://www.vb2themax.com/FileBank.asp?PageID=FileBank

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6909396
Asker : safwan82
Subject : Problem!
Private : No

Question : hello:
i have written a program, but for some reason, when i am running this program, its giving me a syntax error saying missing operator in expression, please help me solve this little problem. Thanks in advance: here is the code:

Private Sub Command4_Click()
Dim crit As String
Dim a As Variant
Dim ws As Workspace
Dim db As Database
Dim rs As Recordset
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase("A:\invoice.mdb")
Set rs = db.OpenRecordset("select * from invoice")
b = Text2.Text
If Option4.Value = True Then
crit = "Invoice Number = '" & b & "'"
rs.FindFirst (crit)
End If
If rs.NoMatch Then
MsgBox "Record not Found"
End If
frminvoice.Show
frminvoice.Text1.Text = rs("Invoice Number")
frminvoice.Text2.Text = rs("Customer Name")
frminvoice.Text3.Text = rs("Number of copies/ Number of hours")
frminvoice.Text4.Text = rs("Form of Payment")
frminvoice.Text5.Text = rs("Total Amount")
End Sub

after the error it is highlighted on
rs.findfirst (crit).

please reply back soon. thanks once more time.

Answer : It appears you may need to use the "[]" method in the event some of your items have a space - from a conversation on the internet:

"Hi All,
(A97)
This should be fairly easy, but I've gotta be blind. I get a "Syntax error
(missing operator) in expression." from the following, but I don't see
where. This is used in a "Find" popform to search a form which will view
archived records by either Record Number or Lab Number.

Dim rs As Recordset
Dim strSearchForm As String
strSearchForm = "frmFindRecordLabNumber"
If Me!cboRecordNumber.Enabled Then
Set rs = Forms![Log In Archive].RecordsetClone
With rs
.FindFirst "Fields_Record Number=" & Me.cboRecordNumber
If Not .NoMatch Then
Forms![Log In Archive].Bookmark = rs.Bookmark
End If
End With
ElseIf Me!cboLabNumber.Enabled Then
Set rs = Forms![Log In Archive].RecordsetClone
With rs
.FindFirst "Fields_Record Number=" & Me.cboLabNumber
If Not .NoMatch Then
Forms![Log In Archive].Bookmark = rs.Bookmark
End If
End With
End If
Set rs = Nothing
DoCmd.Close acForm, strSearchForm

Both cboRecordNumber and cboLabNumber are dimensioned as long integers.
btw, this is not "my" database, I am helping another department, trying to
add a little more functionality to theirs.
This will work in A2k and I've tried to be careful and checked help to see
that I am staying within A97's DAO. but obviously I am missing something.
Thanks in advance for all suggestions and guidance.

gdr
--
Gary D. Rezek
Information Technology Services
South Dakota State University
E-mail: Gary_Rezek@<nospam>sdstate.edu
Message 2 in thread
From: BLP (NOSPAMblpen@bellsouth.net)
Subject: Re: Where am I missing an operator?
Newsgroups: microsoft.public.access.formscoding
View this article only
Date: 2000-12-15 21:58:14 PST


I am not sure what you are trying to do here but I do have some questions.

First why do you have a dot ( .) before each of the statements that begin
.FindFirst . . . Is the Dot supposed to be there?

Also in the 2 statements If Not .NoMatch Then Should there be a
space after If Not before the dot?

Hope this helps

BLP




"Gary D. Rezek" <Gary_Rezek@sdstateREMOVE.edu> wrote in message
news:OBnnU0tZAHA.2184@tkmsftngp04...
> Hi All,
> (A97)
> This should be fairly easy, but I've gotta be blind. I get a "Syntax error
> (missing operator) in expression." from the following, but I don't see
> where. This is used in a "Find" popform to search a form which will view
> archived records by either Record Number or Lab Number.
>
> Dim rs As Recordset
> Dim strSearchForm As String
> strSearchForm = "frmFindRecordLabNumber"
> If Me!cboRecordNumber.Enabled Then
> Set rs = Forms![Log In Archive].RecordsetClone
> With rs
> .FindFirst "Fields_Record Number=" & Me.cboRecordNumber
> If Not .NoMatch Then
> Forms![Log In Archive].Bookmark = rs.Bookmark
> End If
> End With
> ElseIf Me!cboLabNumber.Enabled Then
> Set rs = Forms![Log In Archive].RecordsetClone
> With rs
> .FindFirst "Fields_Record Number=" & Me.cboLabNumber
> If Not .NoMatch Then
> Forms![Log In Archive].Bookmark = rs.Bookmark
> End If
> End With
> End If
> Set rs = Nothing
> DoCmd.Close acForm, strSearchForm
>
> Both cboRecordNumber and cboLabNumber are dimensioned as long integers.
> btw, this is not "my" database, I am helping another department, trying to
> add a little more functionality to theirs.
> This will work in A2k and I've tried to be careful and checked help to see
> that I am staying within A97's DAO. but obviously I am missing something.
> Thanks in advance for all suggestions and guidance.
>
> gdr
> --
> Gary D. Rezek
> Information Technology Services
> South Dakota State University
> E-mail: Gary_Rezek@<nospam>sdstate.edu
>
>
>
>
Message 3 in thread
From: Stephany Young (stephany@sysoft.co.nz)
Subject: Re: Where am I missing an operator?
Newsgroups: microsoft.public.access.formscoding
View this article only
Date: 2000-12-15 22:10:17 PST


It's got nothing to do with the dots. They are absolutely correct.

The problem is that field names with spaces in them need to be wrapped in
[ ] pairs as you have done with [Log In Archive]. Try [Fields_Record Number]


"BLP" <NOSPAMblpen@bellsouth.net> wrote in message
news:#QD2GUyZAHA.2076@tkmsftngp02...
> I am not sure what you are trying to do here but I do have some questions.
>
> First why do you have a dot ( .) before each of the statements that begin
> .FindFirst . . . Is the Dot supposed to be there?
>
> Also in the 2 statements If Not .NoMatch Then Should there be a
> space after If Not before the dot?
>
> Hope this helps
>
> BLP
>
>
>
>
> "Gary D. Rezek" <Gary_Rezek@sdstateREMOVE.edu> wrote in message
> news:OBnnU0tZAHA.2184@tkmsftngp04...
> > Hi All,
> > (A97)
> > This should be fairly easy, but I've gotta be blind. I get a "Syntax error
> > (missing operator) in expression." from the following, but I don't see
> > where. This is used in a "Find" popform to search a form which will view
> > archived records by either Record Number or Lab Number.
> >
> > Dim rs As Recordset
> > Dim strSearchForm As String
> > strSearchForm = "frmFindRecordLabNumber"
> > If Me!cboRecordNumber.Enabled Then
> > Set rs = Forms![Log In Archive].RecordsetClone
> > With rs
> > .FindFirst "Fields_Record Number=" & Me.cboRecordNumber
> > If Not .NoMatch Then
> > Forms![Log In Archive].Bookmark = rs.Bookmark
> > End If
> > End With
> > ElseIf Me!cboLabNumber.Enabled Then
> > Set rs = Forms![Log In Archive].RecordsetClone
> > With rs
> > .FindFirst "Fields_Record Number=" & Me.cboLabNumber
> > If Not .NoMatch Then

Read the rest of this message... (31 more lines)

Message 4 in thread
From: Gary D. Rezek (Gary_Rezek@sdstateREMOVE.edu)
Subject: Re: Where am I missing an operator?
Newsgroups: microsoft.public.access.formscoding
View this article only
Date: 2000-12-18 06:52:15 PST



Thanks Stephany,
Sorry about the delay in getting back to this, I was gone all week-end and
just was able to get to it as I begin another work week.
That was exactly it. I needed the pair of []'s around the field name with
the space in the middle. I used it for [Log In Archive], but bypassed it in
the other field name.
Thanks you for your help

gdr
--
Gary D. Rezek


----------------------------------------------------------------------
QAId : 6916851
Asker : safwan82
Subject : help
Private : No

Question : hello:
i have written a program, and in my program i would like to do the follwing, can u help me.
in the program, i have two forms. in the second form i have created a command button for print, an di would like to know that what code should i put to print both forms and on the paper i printed, i don't wanna see the command buttons i have created on the form. can u please help me.
thanks in advance.
bye
takecare

Answer : Try it like this:

form1.show
form1.print
form2.show
form2.print

You may need to make the buttons invisible after the show commands to ensure they don't print:

cmdButton1.Visible = False

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6957822
Asker : ahmad48
Subject : SQL prob.
Private : No

Question : I have this SQL statement

"select * from table1 order by [field1]"

this sql gives me the info. ordered ascendigly . My Q is how to make its order descendingly. Thanks

Answer : From a SQL friend...

select * from table1 order by [field1] desc

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6979999
Asker : ahmad48
Subject : circling a cell in a flexgrid
Private : No

Question : how can I put circle around a certain cell in a flexgrid as a result of the search ? !

Thanks alot....

Answer : Gleaned from a conversation off UseNet:


.Row = 2
.col = 0
.RowSel = .Rows - 1
.ColSel = .Cols - 1
.FillStyle = flexFillRepeat
.BackColorSel = RGB(255, 0, 0)
.ForeColorSel = RGB(255, 255, 0)
.HighLight = flexHighlightAlways
.SelectionMode = flexSelectionFree
.FocusRect = flexFocusNone
.AllowBigSelection = True



----------------------------------------------------------------------
QAId : 7091263
Asker : Anonymous
Subject : Strings and graphics
Private : Yes

Question : Could you please tell me why this returns a type mismatch?
testpic.Picture = App.Path & "\test\" & testbox.Text & ".bmp"

Answer : I've never worked with this object before, but I suspect that it doesn't want a text string to the ".Picture" property. See this site for more details:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/html/vbobjpicture.asp
Rating : 1


----------------------------------------------------------------------
QAId : 7093439
Asker : ahmad48
Subject : (not) like in SQL
Private : No

Question : I use this SQL " select * from Table1 where [Field1] like" & _
"'" & text1.text & "'"

to find any data that contains (text1.text).
BUT what the SQL will be if i want to find any data that (doesn't)
contain text1.text .In other words, the opposite of "like"

thank you so much my favorite

Answer : I went to a colleague who is a DBA since I'm not a SQL person. He said "NOT like" is a valid term and should do what you're after. Also you can use 'substr' to find if a certain string is in the field, as in:

substr(field1 ,1) !='text1.text'

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Answer : He also sent me this snippet:

" select * from Table1 where [Field1] not like '%TEXT1.TEXT%';


----------------------------------------------------------------------
QAId : 7117632
Asker : ahmad48
Subject : password in db connect
Private : No

Question : I use the following code to connect to a database (db1.mdb) :

Set dbase1 = DBEngine.Workspaces(0).OpenDatabase(App.Path & " \db1.mdb")

It's fine. But if the database has a password, how I can add it to the code to make a connection.


thank you so much

Answer : Try it like this:

Set dbase1 = OpenDatabase ("App.Path & "\db1.mdb", False, False, _
"MS Access;PWD=password")

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 7120663
Asker : Anonymous
Subject : format a disk & delete folders
Private : No

Question : By code , how to format a floppy disk & how to delete all folders in a disk

Answer : Scrounged from the vast internet (I have a recursive delete in my app DiskMaster, but A) it's been a long while and B) I think I used an API)

Recursive delete:

> I am trying to do it all within VB, this shouldn't be that tough.

Crazy,

Well, actually, it's trickier than you think... if you want to cover all possible eventualities.

However... after some deliberation, I am releasing my very own patented
copyrighted bombproof APIproof and completeidiotproof Delete_Tree
function.

Steve.

Public Function Delete_Tree(pathName$, _
Optional flag_recurse, Optional flag_verify, _
Optional exist_skipVarChecks) As Boolean

' recursively deletes a directory and everything in it

' by Steve Smith
' md, Stuff Software Ltd
' (ss.software@zetnet.co.uk)

' requires:
' pathName$ = path to delete, eg. "temp\" or "c:\utils\temp\"
' flag_recurse (optional boolean) = delete sub-directories ? [false]
' flag_verify (optional boolean) = prompt before each delete ? [true]
' exist_skipVarChecks (optional exist): don't specify this

' returns:
' function itself = whether the operation was wholly successful
' (false = has deleted as much as possible)

' NOTES:
' stops the prog if try to delete drive, app.path, DOS or WINDOWS
' exist_skipVarChecks is set for recursive calls back into this fn
' (if it exists, the fn skips error-checking on the 1st 3 vars
' above, which must all be specified to avoid a GPF)

' defaults for optional vars
Const def_Recurse As Boolean = False
Const def_Verify As Boolean = True

' other vars
Dim Filename$, pathName2$, nextFile$, SubDir$
Dim question$
Const DirMask% = vbNormal + vbHidden + vbSystem + vbDirectory
' (** should also include vbArchive ?)

' preform checks on the vars passed in
If IsMissing(exist_skipVarChecks) Then

' (a) make basic syntax checks on pathName$
' & check it for critical directories
Call Check_PathName(pathName$, True)

' (b) check/set flag_recurse
If IsMissing(flag_recurse) Then
flag_recurse = def_Recurse
ElseIf VarType(flag_recurse) <> vbBoolean Then: Stop ' (prog error)
End If

' (c) check/set flag_verify
If IsMissing(flag_verify) Then
flag_verify = def_Verify
ElseIf VarType(flag_verify) <> vbBoolean Then: Stop ' (prog error)
End If

End If

' error-handling
On Error Resume Next ' (for pathName$ not found, file-in-use, etc.)

' if verification is OFF, delete all files in pathName$
If Not flag_verify Then Kill pathName$ & "*.*"

' loop through each remaining file/subdirectory in pathName$
Filename$ = Dir$(pathName$ & "*.*", DirMask%)
Do While Filename$ <> ""
nextFile$ = Dir$ ' (get next entry, in case sub recurses)
If Filename$ <> "." And Filename$ <> ".." Then

If GetAttr(pathName$ & Filename$) = vbDirectory Then

' fileName$ is a sub-directory
If flag_recurse Then

' recurse into it
SubDir$ = pathName$ & Filename$ & "\"
Call Delete_Tree(SubDir$, flag_recurse, flag_verify, True)

' reset Dir$ to previous position:
' read in previously unsuccessful deletes
Filename$ = Dir$(pathName$ & "*.*", DirMask%)
Do While Filename$ <> nextFile$
Filename$ = Dir$
Loop
nextFile$ = Filename$

End If

Else

' fileName$ is a file: verify & delete
' (note, if flag_verify is false here, the 'kill *.*'
' failed to delete some files, so ignore them)
If flag_verify Then
question$ = "Delete file " & pathName$ & Filename$ & " ?"
If MsgBox(question$, vbYesNo + vbExclamation) = vbYes Then
Kill pathName$ & Filename$
End If
End If

End If

End If
Filename$ = nextFile$
Loop

' remove the directory
' (causes error if files or sub-directories remain)
Err.Clear
RmDir pathName$
Delete_Tree = (Err = 0)

End Function

********************************

too long so floppy on next section


Answer : Formatting a floppy:

Here is the code on How to Format Floppy Disk using API. Note -- This code
can format your Hard Disk as well, so you should be careful.


In Declaration

Private Declare Function SHFormatDrive Lib "shell32" _
(ByVal hwnd As Long, ByVal Drive As Long, ByVal fmtID As Long, _
ByVal options As Long) As Long
Private Declare Function GetDriveType Lib "kernel32" Alias _
"GetDriveTypeA" (ByVal nDrive As String) As Long

Add 2 command buttons named :

cmdFormat and cmdDiskCopy

Private Sub cmdFormatDrive_Click()
Dim DriveLetter$, DriveNumber&, DriveType&
Dim RetVal&, RetFromMsg%
DriveLetter = UCase(Drive1.Drive)
DriveNumber = (Asc(DriveLetter) - 65) ' Change letter to Number: A=0
DriveType = GetDriveType(DriveLetter)
If DriveType = 2 Then 'Floppies, etc
RetVal = SHFormatDrive(Me.hwnd, DriveNumber, 0&, 0&)
Else
RetFromMsg = MsgBox("This drive is NOT a removeable" & vbCrLf & _
"drive! Format this drive?", 276, "SHFormatDrive Example")
Select Case RetFromMsg
Case 6 'Yes
' UnComment to do it...
'RetVal = SHFormatDrive(Me.hwnd, DriveNumber, 0&, 0&)
Case 7 'No
' Do nothing
End Select
End If
End Sub

Private Sub cmdDiskCopy_Click()
' DiskCopyRunDll takes two parameters- From and To
Dim DriveLetter$, DriveNumber&, DriveType&
Dim RetVal&, RetFromMsg&
DriveLetter = UCase(Drive1.Drive)
DriveNumber = (Asc(DriveLetter) - 65)
DriveType = GetDriveType(DriveLetter)
If DriveType = 2 Then 'Floppies, etc
RetVal = Shell("rundll32.exe diskcopy.dll,DiskCopyRunDll " _
& DriveNumber & "," & DriveNumber, 1) 'Notice space after
Else ' Just in case 'DiskCopyRunDll
RetFromMsg = MsgBox("Only floppies can" & vbCrLf & _
"be diskcopied!", 64, "DiskCopy Example")
End If
End Sub

Add 1 ListDrive name Drive1

Private Sub Drive1_Change()
Dim DriveLetter$, DriveNumber&, DriveType&
DriveLetter = UCase(Drive1.Drive)
DriveNumber = (Asc(DriveLetter) - 65)
DriveType = GetDriveType(DriveLetter)
If DriveType <> 2 Then 'Floppies, etc
cmdDiskCopy.Enabled = False
Else
cmdDiskCopy.Enabled = True
End If
End Sub


----------------------------------------------------------------------
QAId : 7126719
Asker : aserebry
Subject : .frx files
Private : No

Question : Do you know what is .frx file in VB? And also can I create it?

Thanks a lot.

Answer : They are created to track the changes made at design-time to binary resources. The following is taken from http://www.vb-helper.com/tips14.htm:

"About FRX Files

Someone wrote to ask me about FRX files. What are they? How can you edit them? Can you do without them?

Visual Basic stores binary information in the FRX files. For example, if you set a form's Picture property at design time, Visual Basic stores the image in this file. If you delete the file and try to open the project, you get an error and all the information in the file it lost to the project.

I don't know how to edit these files directly. If you replace the form's Picture property at design time, Visual Basic replaces it in the FRX file, but I don't know how to look at the file's contents.

There isn't really any way to do without these files unless you never load binary information like pictures at design time. You could store pictures and other information in a resource file and load it at run time, or you could store this information in separate files (bitmap files, etc.) and load it at run time. This doesn't really give you much benefit, though some would argue that being able to switch resource files at run time is worth it.

These method have the definite disadvantage that they require these files to be there at run time. If you let Visual Basic store the information in FRX files, then it is included in the EXE when you compile the program."

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 7138423
Asker : sammy_lb_2000
Subject : Windows API functions...
Private : No

Question : Hello paul,

I need to borrow some of your programming tricks,
in programming with windows api calls, I would
like to know how to make a silver colored strip on
the bottom of my screen, that is 80 columns wide,
just like the one we get with windows 98 that has
the start botton? I went to www.vbapi.com to look
for this api call, but I did not know what to
look for and what is the needed parameters for
the call? I would like to display this strip in
my humble COBOL program.
thanks a lot for your help...!
sammy. ;-)

***

Answer : Never done this one, bud. The only experience calling APIs was in my DiskMaster app a few years back.

This reference of functions may help. Once you know which one you need finding examples of calling it should be pretty easy.

http://www.vbapi.com/ref/funca.html
Rating : 5


----------------------------------------------------------------------
QAId : 7157627
Asker : ahmad48
Subject : compress a file by code
Private : No

Question : If I want to compress a file ( or a folder ), how to do this by the code.
Can I use WinZip to do such thing.If it is how to do it by code.Please, Do not
forget to give me the reverse way.

Thank you so much for your
works and responses,

Answer : I created a standard Form and added a single command button to it. Below is the code to use to invoke WinZip and compress some files:

Private Sub Command1_Click()
params = " -min -a -r c:\test1.zip c:\windows\*.bmp"
Shell ("c:\program files\winzip\winzip32.exe" & params)
End Sub


Add a second button (or just erase the code and put the following in) and use the code below to extract the files:

Private Sub Command1_Click()
params = " -min -e -o c:\test1.zip c:\temp\stuff4"
Shell ("c:\program files\winzip\winzip32.exe" & params)
End Sub


--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 7162317
Asker : bottaxxgp25
Subject : How can i determinate the dimension of a file
Private : No

Question : HI from Italy

There is a proprerty in VB6 which tell me the dimension of a file.

I can determinate the name of a file, but i want now deteminate the dimension in KB.

Thank for all

Gian Paolo from Milan.

Answer : I assume you mean find the file size when you say dimension. So here is some code that will do just that:

Option Explicit

Private Sub Form_Load()
Dim PathToFile As String
PathToFile = "C:\Temp\Temp.txt"
MsgBox "The size of " & PathToFile _
& " is " & GetFileSize(PathToFile)
End Sub

Private Function GetFileSize(PathToFile As String) As Long
'See if the file exists first so you don't
'get an error 53
If Len(Dir(PathToFile)) > 0 Then
GetFileSize = FileLen(PathToFile)
End If
End Function


--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities


Rating : 4


----------------------------------------------------------------------
QAId : 7202761
Asker : Lucron
Subject : Directory
Private : No

Question : Hallo!

How I can know if a directory it exists?

Thanks!

Answer : Gleaned from a conversation on the internet:

If Dir(Path, vbDirectory + vbHidden + vbReadOnly) <> "" Then
If GetAttr(Path) And vbDirectory Then
MsgBox ("Folder exists")
If GetAttr(Path) And vbHidden Then MsgBox (" but hidden")
If GetAttr(Path) And vbReadOnly Then MsgBox (" but read only - can
not be deleted")
Else
MsgBox "exists as file"
End If
End If

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4


----------------------------------------------------------------------
QAId : 7218570
Asker : ahmad48
Subject : link to Word _document
Private : No

Question : I want to link to a Word document so I write the following (if you have something better please code it to me) :

=================
dim x as object
set x = createobject("word.application")
x.document.open="c:\windows\desktop\doc1.doc"
x.visible=true
=================

In advance, i put a reference to WORD Library.

My Problem is when executing it i've got a run-time error telling :


---------------------------------------------
| Run-time error '-2147417846(8001010a)': |
| Automation error |
| |
----------------------------------------------

But when i use Excel or any other Office items instead of Word I don't have that error. I've made two things to solve it :

I reinstall VB6 but nothing seems to happen.Then I reinstall Word2000 but nothing is done as well.
By the way,I have done this before it worked very well. This time I face this problem. What do suggest?

Please help me,

Answer : Some folks on sites I've seen say improperly-registered DLLs can cause this and that re-registering your appropriate DLLs can fix it.

Here is a snippet of a conversation I found on the topic along with the correct link I found (his was broken) to the document he's referring to:

"A common cause for this error is a problem with intl settings in the
win.ini file. If this section is corrupt or missing, then you can get
this error.
Go into control panel and international or regional settings (win 3x or
windows 95 respectivley) and change the setting from english US to
Canada english. get out of windows , go back in and change back to US.
You may also want to take a look at Q145682 at www.microsoft.com/kb.
This article has the intl section of the win.ini file in it as it should
be."


http://support.microsoft.com/default.aspx?scid=kb;EN-US;q145682

It seems some people are noticing the *quantity* of interaction matters when controlling apps from VB:

http://groups.google.com/groups?q=vb+%22run-time+error%22+%22automation+error%22&start=10&hl=en&selm=01bcc948%24cc8c3420%24f3050626%40entwydim&rnum=12

This person suggests that timer routines should have an error-handler that repeats the code section:

"You can fix it by putting "ON ERROR RESUME NEXT" into every single timer routine that you have."

Finally, here is a load of useful information on the subject of OLE automation problems:

http://vbwire.com/advanced/com.asp

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 7234605
Asker : louise_ruthe35
Subject : Accessin Excel using VB
Private : Yes

Question : Hi

I am trying to access a Microsoft Excel Spreadsheet using visual basic. (I am writing independant VB code, not an Excel macro).
Once I have accessed the spreadsheet I want to read through the cells to manipulate the data.
Can you give me some ideas of how this can be done.
I am looking into using ADO, do you have any views on it's functionality?

Thanks

Lou

Answer : I've not done this myself, but here are many conversations on the topic:

http://groups.google.com/groups?q=vb+excel+read+cells&hl=en



----------------------------------------------------------------------
QAId : 7370246
Asker : snkscore
Subject : VB Learning Edition
Private : No

Question : Do you know if a person who owns VB6 Learning Edition, can sell his/her programs, or is there some kind of licence problem with that?

Do you need to get Pro in order to distribute, or is Learning Edition ok?

Answer : I think that you are allowed to distribute the apps you create with it, but you can't charge anything for them.
Rating : 5


----------------------------------------------------------------------
QAId : 7380691
Asker : kirby6
Subject : Autorun
Private : No

Question : I have an application that I would like to have autorun when the CD is inserted to the drive. As well, I would like to create a key for it. Do you know how to do this? I tried to look for something on VB World and got some code that I do not know what to do with.

THX
Kirby

Need More Information : What do you mean a key? And you want to put this app on a CD and have the app autorun when a user inserts the CD?

FUQuestion : By key I mean a serial number.

I used package and deployment to create the setup package. It creates a support folder, a cabinet file, a setup icon that has the description "Setup Bootstrap for Visual Basic Setup Toolkit" and SETUP.LST file. I also made an Autorun.inf file containing

[autorun]
OPEN=setup

Under properties the setup icon says it is an application. I am not sure if this is an exe file.

Ordinarily after copying these files to the CD when you put the CD in the drive and click the set up icon the typical Windows installation procedure starts and the application is installed as normal. I just want to be able to have the same process occur only using an autorun feature.


Answer : Just put the autorun.inf file in the root of the CD with the following:

[autorun]
OPEN=autorun.exe

where 'autorun.exe' is the name of your EXE you want to run when the user puts the CD in the drive.

About the serial number - are you trying to create a software protection or tracking scheme? If so I've never implemented one so I'd be starting from where you are.

FUQuestion : I tried using the inf file to do what we have been talking about, however the icon that you double click on to start the installation does not seem to be an exe file. In the properties of this icon it has this as a description. Setup Bootstrap for Visual Basic Setup Toolkit. It says that this is an application but does not have an exe extension.

When you double click the setup icon the typical Windows installation starts but I do not know what to call this setup icon since all it says under it is "setup", without an extension. Again it was created by package and deployment using the package button when package and deployment starts.

I wanted to use the key for software protection.

Kirby

Need More Information : What is the extension of the file that you double-click to start the setup?

As for protection why not just incorporate a check for the existence of a registry key you put in place after a user registers and make the key be a code you generate by pulling some unique numbers from known locations in their registry and apply an algorithm to them?

Say grab his NIC's MAC address (grab it from an "ipconfig /all" in NT/2K/XP or with "winipcfg /batch") and another unique number to generate your code you'll store in his registry. Each time the app loads check for the prescence of the key in the registry and use the same algorithm to pull the current machine's MAC and other unique numbers and see if the results match the expected result.


--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 7620941
Asker : zort15
Subject : A few questions
Private : Yes

Question : I'm new to the world of visual basic and i had a two questions

Fisrt, How do you create a new shape with code

Second, How can you get two forms to communicate with each other

Answer : You'll probably have to use line-drawing functions to draw shapes:

http://groups.google.com/groups?q=vb+line+function+%22draw+lines%22&hl=en

Forms can pass information or invoke procedures. One way is to prefix the object's name with the form name, for example:

(from code in form2)

form1.mytextbox.text

Also you can setup global variables in the primary form that can then be updated or accessed by any form in your program. Those will be defined in the (General) (Declarations) section if memory serves me.



Rating : 4


----------------------------------------------------------------------
QAId : 7684470
Asker : tfy2
Subject : How to open or call a html file
Private : No

Question : Dear Experts,
How to call a html file from VB and the html file is in local hard disk. I understand Shell command work for Exe file but it didnt help in html file.

Thanks

Answer : Try invoking their Internet Explorer executable (IEXPLORE.EXE) with Shell and pass as an argument the path and filename of the HTML file you want them to view.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 7849509
Asker : jahangeer_m
Subject : Stack error after crystal reports control
Private : No

Question : Hello Dear Expert.

I made a database project. for reporting i used crystal report writer 8.5. it works fine from VB. and also works fine if i run the exe file. but when i try to make an installation from VB . it gives up STack error.

then i tried to make a simple project using the only crystal report project on a form. but it still gives the problem,

What might be the problem??

Thanks for answering me.
Jahangeer Mirza

Answer : Perhaps a corrupted OCX file? I would replace the OCX files that relate to Crystal Reports.


----------------------------------------------------------------------
QAId : 7884072
Asker : jahangeer_m
Subject : VB reports
Private : No

Question : Is there any web site with many many examples or tutorials of Visual basic Reports tools

or alternatively can u pleaase mail me some code to help make each secion of a report in VB


Thanks
Jahangeer Mirza

Answer : http://www.devx.com/
http://www.blackbeltvb.com/

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 7918181
Asker : domenic_colantoni
Subject : IP address on the network
Private : Yes

Question : What you know would an easy way (or any way) in finding out if a particular Workstation is on the network using its IP address in Visual Basic?

Thanks in advance!

Domenic

Answer : How about just execute the ping.exe file on the local machine (all versions of Windows after Windows 95 have this) and echo the result to a temporary file, and then examine that file.
Rating : 5


----------------------------------------------------------------------
QAId : 7986514
Asker : Anonymous
Subject : vb and word
Private : Yes

Question : Hiya

Please help..


How do get VB to take the information from text boxes and plug it into a sentance in word

eg.

textbox 1 = "David"
textbox 2 ="23"
text box3 "Boy"

In VB INTERFACE....TAKEN FROM ACESS DB to

Micosotft word doc...

My name is [textbox1]
I am [textxbox2]
I am a [textbox3]

BASICLY CLICK ON A BUTTON AND IN VB TO OPEN WORD AND PLUG THE WORD FROM THE TEXT BOX INTO THE APPRPOPIATE PLACE IN A WORD DOC.

Please need example..

Thank you

Answer : Try this Word from VB tutorial:

http://www.vbsquare.com/beginning/begword-demo/frmCreateADoc.frm.html


----------------------------------------------------------------------
QAId : 8107984
Asker : ahmad_ahmad
Subject : VB6 & SQL server2000
Private : No

Question : I recently decide to start build up my data with SQL server 2000 instead of MS Access. So I want a full example ( just a list of procedures ) from making a database in SQL server 2000 till I connect it successfully with VB6 . Please tell me if you know or at least lead me to a site that deals with beginners in ( linking SQL server 2000 with VB6 ). thank you very much.

Answer : Here are several tutorials, including one on SQL:

http://www.vbinformation.com/tutor.htm
Rating : 2


----------------------------------------------------------------------
QAId : 8246701
Asker : Anonymous
Subject : Creating controls at run time
Private : No

Question : Is it possible to create instances of new controls at run time?. I am trying the following code

Dim tx as Textbox
tx.Visible = True

But it gives the error 'Object variable not set'.

I know I can accomplish this by placing a text box and then using the LOAD command. But I want to create controls on the fly and place it on the form at run time. Is there any way mate?

Answer : Here's a tutorial on the very subject:

http://www.vbexplorer.com/VBExplorer/vb_feature/april2000/april2000.asp

PowerUsers.info - Paul Doherty Askme Archive of Questions and Answers

Return to AskMe Archive Main Page

Return to Main PowerUsers.info Main Page