Area : BASIC7 Subj : Mouse ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Question?? > Let's say we have a screen that displays COLOR 15, 3, 0 and we > are using SCREEN 0. Then you have a row and column of numbers: > If I want to use a mouse to select a number, to preform a > function, how would I go about that? An example would be nice. I > have some mouse code but I don't really understand how to have the > mouse return a number or I guess really don't know how to make it > work. If you have been where I am, and can help, it would be > greatly apreciated. Possible Solutions!! The mouse doesn't directly return a (column) number, you could use a FUNCTION routine to convert the x,y position of the mouse cursor into a column number. Let's call it "FUNCTION MousPos2ColumNbr%(MousePosCol, MousePosRow)"... This function is called whenever the correct mousebutton is pressed, preferably the left mouse button. Your main routine will have to cover that. You first 'read' the mouse cursor position. If the current cursor position is outside the upper or lower rows of the numbered columns that the result will be 0. For example: ------------ SELECT CASE MousePosRow CASE IS >= 4, IS <= 12 ' You can used equal space between the three numbered columns. ' To find out which column is selected you take the mouse-cursor- ' column-position and divide it by the in-between-space. ' For example: SelectedColumn = (MouseCol \ ColumnSpace) + 1 SelectedRow = MousePosRow - OffsetRow ' OffsetRow is starting row ' where numbered columns begin MousPos2ColumNbr% = SelectedColumn * 10 + SelectedRow CASE ELSE 'Outside the numbered colums END SELECT The above is purely a guideline so no guarantee whatsoever, but this is the first thing that came into my mind of how to solve such a 'problem'. The select of the correct column depends on the width of each column so you'd have to fiddle around with that. Area : BASIC7 Subj : DOOR.SYS Format ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ > A while back someone posted the format to DOOR.SYS in this conference. > I thought I'd saved it but come to find that I no longer have it. Would > someone kindly repost the information. I'd really appreciate it. This is from Maximus, written for Mecca. Should be self-explanatory, but if you have questions translating it, let me know. [delete]Door.Sys [open]Door.Sys [write]COM%P:[comment COM port] [write]%b[comment Baud rate] [write]8[comment Stop bits] [write]%k[comment Node number] [write]N[comment DTE locked? -- Set to baud rate if running a locked port!!!] [write]Y[comment Screen display] [write]Y[comment Printer toggle] [write]Y[comment Page bell] [write]Y[comment Caller alarm] [write]%n[comment User's name] [write]%c[comment User's city] [write]%h[comment Home phone] [write]%h[comment Work/data phone] [write]%e[comment User's password] [write]%o[comment User's priv level] [write]14[comment # of times on] [write]01/01/90[comment Last date called] [write]%T[comment Seconds remaining] [write]%t[comment Minutes remaining] [colour write]GR[comment 'GR' for graphics] [endcolour nocolour write]NG[comment 'NG' for TTY] [endcolour][write]%E[comment Page Length] [expert write]Y[comment Help mode] [regular write]N [novice write]N [write]1,2,3,4,5,6,7[comment Confs reg'd in] [write]1[comment Conf last in] [write]01/01/99[comment Expiration date] [write]%u[comment User number] [write]X[comment Default protocol] [write]0 [write]0 [write]0 [write]9999 Area : VISUAL_BASIC Subj : Shell help! ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Presenting Problem: > Using Vb 3.0 pro, I need to shell using a command line : > x=shell("playact.exe wavmail.acp",1) > But when I use the following code, it locks up then I have > to ctr-alt-del and force windows to close my app! > x = Shell("playact.exe wavmail.acp", 1) > 15 > 'Find out if the specified application is running. > If FindWindow(0&, "Action! Player for Windows") = 0 Then > AppActivate "Action! Player for Windows" > SendKeys "%(F)", True > SendKeys "%(X)", True Possible Solutions: Once the Shell has been called the next command executes; it does not wait for the shelled app to finish. You need to trap when the shell is done. One method is to use GetModuleUsage. However, this is of value only if you are shelling to a dos app, or the user closes the shelled app. If the title of the app changes as it's play/pause/state is encountered, then you could use the FindWindow in a loop, looking for the appropriate word...ie FindWindow(0, "The App : Finished") If playact.exe is your program, you could program this versitility into it. But then too, if it is your app, it would be more efficient to pass it a command parameter with the file to play, then perform the action specified, i.e. Shell("playact.exe wavmail.acp /w /c", 1) where /w = play a wave and /c = close when done. If there is nothing in the app to signal it's completed state, I can't think of a way to determine if the wave has finished playing or not. Here is the GetModuleUsage method, FYI.... Declare Function GetModuleUsage% Lib "Kernel" (ByVal hModule%) Declare Function FindWindow Lib "User" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer Global Const WM_CLOSE = &H10 x% = shell("someapp.exe",1) Do while GetModuleUsage%(x%) Doevents Loop hWndPlayer% = FindWindow%(0&, "The Apps Title Text") if hWndPlayer% > 0 then s& = SendMessage&(hWndPlayer%, WM_CLOSE, 0&, 0) end if >Declare Function FindWindow Lib "User" (ByVal lpClassName As Any, ByVal > lpCaption As Any) As Integer > Dim continue > messagebeep 16 > continue = MsgBox("It is recomended that you have a sound card and > at least 4 megs of RAM and a 486/sx-33 chip as the next section > is quite extensive! " & Chr(13) & Chr(10) & " " & Chr(13) & > Chr(10) & " Do you wish to continue?", 20, "Please Read . . .") > Select Case continue > Case 6 'Yes button pressed > GoTo 10 > Case 7 'No button pressed > GoTo 20 > End Select > 10 > x = Shell("playact.exe wavmail.acp", 1) > 15 > 'Find out if the specified application is running. > If FindWindow(0&, "Action! Player for Windows") = 0 Then > AppActivate "Action! Player for Windows" > SendKeys "%(F)", True > SendKeys "%(X)", True > GoTo 20 > Else > GoTo 15 > End If > 20 > End Sub Area : VISUAL_BASIC Subj : CONSTRAINT woes ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Problem?? > I'm using VB4 Pro 32bit. > I have dim'd everything properly, created a table for my database using > CreateTable, and set up fields and indexes for it. > Now I want to use the SQL ALTER TABLE to add a three-field index, but I > can't get it to go. In fact, I've never gotten any SQL statements to work > any time I've tried them. Hopefully someone can see something I'm doing > wrong. > Here's the line that is currently causing the problem: > db.Execute "ALTER TABLE TableName ADD CONSTRAINT CardIdx PRIMARY KEY > (Company, Year, Number)" Possible Answers; > The problem could be the word PRIMARY KEY. In the example in the > manual it just says PRIMARY. Area : VISUAL_BASIC Subj : ole2ui.dll missing ? ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Problem: > When I compile some programs using the setup wizard in VB 3.0 pro > I get the message 'Where is OLE2UI.dll'. > I have searched all my hard disc but can't find it. > I seem to remember a similar thread asking the same thing a while > ago but it went over my head at the time :< Answer: 1. You don't need it. I don't remember where exactly, but you can delete any reference to it in your setup files. 2. Sounds like you are using the older version of the Setup Wizard. You either need to get the newer version (SETUPK.EXE, ftp sites listed below) Or edit the setupwiz.ini file. Remove the reference to OLE2UI.dll It was part of the beta of VB3 and the reference was not removed in the final release. ftp.cica.indiana.edu/pub/pc/win3/programr/vbasic/ ftp.cdrom.com/pub/cica/win3/programr/vbasic/ wuarchive.wustl.edu/pub/win3/programr/vbasic/ mirrors.aol.com/pub/cica/pc/win3/programr/vbasic/ ftp.pht.com/pub/mirrors/cica/win3/programr/vbasic/ ftp.agt.net/pub/cica-win3/programr/vbasic/ ftp.hawaii.edu/pub/ibmpc/win3/programr/vbasic/ ftp.cica.indiana.edu/pub/pc/win3/programr/vbasic/ ftp.cdrom.com/pub/cica/win3/programr/vbasic/ wuarchive.wustl.edu/pub/win3/programr/vbasic/ mirrors.aol.com/pub/cica/pc/win3/programr/vbasic/ ftp.pht.com/pub/mirrors/cica/win3/programr/vbasic/ ftp.agt.net/pub/cica-win3/programr/vbasic/ ftp.hawaii.edu/pub/ibmpc/win3/programr/vbasic/ uiarchive.cso.uiuc.edu/pub/systems/pc/cica/win3/programr/vbasic/ ftp.funet.fi/pub/msdos/Mirrors/CICA/programr/vbasic/ Or try the MS Download Service (BBS) at: 206-936-6735 3. You need the updated setup program, free from MS. OLE2UI,DLL never existed in the final product, and in the shipped setup program this was acknowledged as a bug by MS. Area : VISUAL_BASIC Subj : Path for data files???? ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Problem: > I have a couple of questions for someone more advanced than me > (won't take much). I have written a program that uses data files that > are stored on c:\cross on my hard drive and I have written the VB 4.0 > Pro. to look for them there (hard coded). What I want to know is how > do I write an .ini file so I'm not dependent on the hard coded path? > If I give this program out and the user puts the files in another > directory it won't find the files and operate. I've looked in the help > files but can't find the kind of information that would answer this > question. Possible Solutions: 1. I think an .ini file is basically a text file with an .ini extension. When your user changes something like the path name, I think you can just save that text to the .ini (text) file and then load it again when needed. Can't say I've tried this, but I have done similar things with .txt files. 2. I have written code without using a path just the filename, when you don'd specify a path then your application will look inside of the directory where it is running from. That way no matter where someone installs your program it will always be able to find the datafiles. There is one small catch, if you do any changing of the current path such as through the file common dialog box or using the VB functions to change drive or path then you must reset these back to your application's path when you are done or the program will look in whatever path was last used. Hope this helps, Anyone have a better way than this??? 3. If you're looking for a file in the application directory, use App.Path and tack it to the beginning of the file name. Don't forget to add the backslash before the file name, as in FileName = App.Path & "\" & MyFile. Here's a few other common ones... GetWindowsDirectory and GetSystemDirectory will find the Windows and Windows/System directories. Someone else around here may have figured how to find the Win95 desktop, recycle bin, and other virtual folders. I haven't yet had the time or the need, but I believe you need to call SHGetSpecialFolderLocation or something like that. Also, check out this function... The SearchPath function searches for the specified file. DWORD SearchPath( LPCTSTR lpszPath, // address of search path LPCTSTR lpszFile, // address of filename LPCTSTR lpszExtension, // address of extension DWORD cchReturnBuffer, // size, in characters, of buffer LPTSTR lpszReturnBuffer, // address of buffer for found filename LPTSTR *plpszFilePart // address of pointer to file component ); Parameters lpszPath Points to a null-terminated string that specifies the path to be searched for the file. If this parameter is NULL, the function searches for a matching file in the following directories in the following sequence: 1. The directory from which the application loaded. 2. The current directory. 3. The 32-bit Windows system directory. Use the GetSystemDirectory function to obtain the path of this directory. The name of this directory is SYSTEM32. 4. The 16-bit Windows system directory. There is no Win32 function that obtains the path of this directory, but it is searched. The name of this directory is SYSTEM. 5. The Windows directory. Use the GetWindowsDirectory function to obtain the path of this directory. 6. The directories that are listed in the PATH environment variable. Read the SDK docs in the MSDN starter kit for details and related functions such as FindFirstFile, etc. Area : VISUAL_BASIC Subj : QBasic in Visual Basic ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Question: I'm wondering if many of the QBasic commands are used in Visual Basic, commands like DEF SEG, PEEK, POKE, INKEY$. Answer: You can forget about all of the above: VB doesn't like us playing directly with the hardware or with memory... there are DLLs around that will let you get around some of those limitations. Mind you, the concept of INKEY$ is contrary of the VB programming model. You should have keys (KeyPress event, for example) trigger actions, rather than loop waiting for them to occur. Area : VISUAL_BASIC Subj : A small question. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Question: Is there a simple way to find the _last_ occurance of a character in a string? Answer: 1. Presently, when I need to find the last location of a "\" in a pathname, I use a loop to check the string backwards from end-to-start, checking each character. I wish there was a "direction of search" argument for InStr as well, but, alas (at least in VB3), you have to loop until no more are found. For example: I% = 0: J% = InStr(TheString$, "\") While J% I% = J% J% = InStr(J% + 1, TheString$, "\") Wend ' At this point, I% contains the location of the last "\" 2. You're parsing the filename, yes? Give this a try: Function ParseFileName (sFileIn As String) As String Dim I As Integer For I = Len(sFileIn) To 1 Step -1 If InStr("\", Mid$(sFileIn, I, 1)) Then Exit For Next ParseFileName = Mid$(sFileIn, I + 1, Len(sFileIn) - I) End Function ' Example: Dim sTargetString As String sTargetString = Text1.Text 'Being the string to pass 'Display the filename Label1 = ParseFileName(sTargetString) 3. You can use INSTR to find the position of the character. You still have to use this within a loop, but you don't need to check each character. Here's a function I wrote for stripping the filename away from a fully qualified pathname. Private Function StripPath(ByVal sFile As String) As String 'Removes the path from the passed string and returns just 'the file name. Dim nBackSlash As Integer Dim nPrevPosition As Integer 'loop until the last backslash has been found Do nPrevPosition = nBackSlash nBackSlash = InStr(nPrevPosition + 1, sFile, "\") Loop Until nBackSlash = 0 StripPath = Mid(sFile, nPrevPosition + 1) End Function This function can be easily modified to strip the filename and return the path instead. þ