|
Dave Kreskowiak wrote: Zero if it's not found (False), a value greater than 0 if it is found (True) and -1 if it is NOT found (True!).
In other words, "if it's not found it returns 0, but if it's not found it returns -1".
Well, that's not going to confuse matters at all!
If the sub-string is not found, it returns -1; if it is found, it returns the zero-based index at which it was found. It the sub-string is found at the start of the string, it returns zero.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Crap.
Mistyped that one! It should be if the string to search for is Empty, 0 is returned.
|
|
|
|
|
You've still got "a value greater than 0 if it is found", which should be "greater than or equal to 0" - if the sub-string is found at the start of the main string, IndexOf will return 0 .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Grrr....fixed!
I picked the wrong week to stop sniffing glue!
|
|
|
|
|
Is there a TimeZoneInfo in VB.NET 2005, all I can use is TimeZone.
that does't mean that I can't do it
|
|
|
|
|
The TimeZoneInfo class was added in .NET 3.5, so you'll need Visual Studio 2008 or higher.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello,
I am trying to get my program to open an external program. I also plan to make this portable, so I made a folder for my program to go to.
It's like this: Click OpenOffice and my program manager will go to:
Vegrard Suite\Vergard\OpenOffice\program\soffice.exe
This folder is located in the root directory of the program; wherever this root directory is in will make the program read the folder that's in its root directory.
The problem, however, is that I can't get the program to launch without going to a fixed location on the C drive "C:\Users\User\My Documents\Visual Studio 2010\Projects\Vergard Suite\Vergard\OpenOffice\program\soffice.exe". The idea is that wherever you put the application folder (Vergard Suite) , the program will always refer to the folder that the application is in to open the program (Vergard Suite\Vergard\); therefore, it can be made portable (like Windows 3.11: wherever the WINDOWS directory is located, Windows will go to the program's folder that was specified).
How do I get this to work???
Marquis Kurt
---------------------------
Parament Technologies
|
|
|
|
|
Your question doesn't make a lot of sense. It may be obvious to you but the description is missing some critical detail.
Why would OpenOffice be under your Projects folder?
There are two paths to be aware of when launching an application. The first is the fully qualified path to the executable you're trying to launch. What this path contains is entirely dependent on when the application is installed. How are you getting this path?
The second is the "Startup Directory". This is what the current path should be when the target application is launched. Normally, this path doesn't matter at all, but some apps do require it. How are you going to determine if the app requires this and how are you going to determine what this path is?
There are the "well-known" paths that Windows supplies. Using the Environment.GetFolderPath() method will return the path of certain folders using an enumeration value to determine which folder you want the path for. See the documentation for GetFolderPath()[^] and SpecialFolder enumeration[^] for more information.
|
|
|
|
|
This is what I mean:
Say you want to launch a program called "Banana" through the program manager. The program manager is located on your desktop. The program manager will check inside its folders, not the entire C: drive for that particular PC, for this program, and finds it at:
\Vergard\Banana\Banana.exe
The program will then launch Banana.exe from \Vergard\Banana\Banana.exe, not C:\Users\Me\Desktop\Vergard Suite\Vergard\Banana\Banana.exe.
Now say that you copy Vergard Suite to your flash drive. You go to your friend's computer and try to launch your program through the program manager. What's supposed to happen is Vergard will go to \Vergard\Banana\Banana.exe, not C:\Users\Me\Desktop\Vergard Suite\Vergard\Banana\Banana.exe. This can be proven effective if it works. It's like that command in batch scripts: ".\Vergard\Banana\Banana.exe".
How can I get it so that my program mananger will execute a command similar to the bstch command to open that file, no matter where the program manager's files are?
Oh, about the OpenOffice: I put it in the Projects folder to test the program manager's ability to OpenOffice.
|
|
|
|
|
You still have to build a complete path to the .EXE, not a relative one. This is because the relative path would be relative to whatever the "current directory" is and that can change without your code knowing it.
Since the folder is under your program files folder, you can get the path to your own .EXE by using Application.StartupPath. You can then build the remaining path to the target .EXE using the methods in the Path class[^].
|
|
|
|
|
I just realized this... Is it possible to have my application run that bstch script command? I know people have made CMD redirects before, so theoretically, it should work, right?
|
|
|
|
|
What "bstch" command? There's no such thing in Windows and any script lanugage I know of.
|
|
|
|
|
Oops... I meant batch script.
http://commandwindows.com/batch.htm
|
|
|
|
|
Yes, you can run a batch script using the Process class.
|
|
|
|
|
Open a command window. Type "Path".
Those are the folders that Windows searches if you do not specify a location. If it ain't in there, it won't be found, unless you specify a full path.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have a CommonDialog that uploads a picture (jpeg) and then saves it to a specific file. It works fine in Windows XP, but not in Windows 7. I have it open in My Computer and then save to a remote temp file. The prblem is that Windows 7 gives you the last location you either viewed or saved to and not the folder that you hard coded into the VB6 program. Is there a way around this? Is there a way to turn the option off in Windows 7 or a different Dialog to use in VB6?
Here's my Code:
Public Sub subUploadImage()
Dim stFromFile As String
Dim stToFile As String
Dim inCnt As Integer
st_MYCOMPUTER_CLSID = "::" & "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
stPath_Ols_Photo_Temp = "i:\programs\old\photo_temp\"
On Error GoTo ErrorHandler
frmSubjectMaint.CommonDialog1.InitDir = st_MYCOMPUTER_CLSID
If frmSubjectMaint.CommonDialog1.Flags = cdlCancel Then
Exit Sub
End If
frmSubjectMaint.CommonDialog1.Filter = "JPEG Files (*.jpg)|*.jpg"
frmSubjectMaint.CommonDialog1.FileName = ""
frmSubjectMaint.CommonDialog1.Flags = cdlOFNHideReadOnly + cdlOFNOverwritePrompt
frmSubjectMaint.CommonDialog1.ShowOpen
stFromFile = frmSubjectMaint.CommonDialog1.FileName
frmSubjectMaint.CommonDialog1.InitDir = stPath_Ols_Photo_Temp
' frmSubjectMaint.CommonDialog1.InitDir = stPath_Ols_Photo
frmSubjectMaint.CommonDialog1.Filter = "JPEG Files (*.jpg)|*.jpg"
frmSubjectMaint.CommonDialog1.FileName = mskSsn.Text
stToFile = frmSubjectMaint.CommonDialog1.FileName & ".jpg"
frmSubjectMaint.CommonDialog1.ShowSave
FileCopy stFromFile, stPath_Ols_Photo_Temp & stToFile
' FileCopy stFromFile, stPath_Ols_Photo & stToFile
If Dir(stPath_Ols_Photo_Temp & stToFile) <> "" Then
If Dir(stPath_Ols_Photo & stToFile) = "" Then
FileCopy stPath_Ols_Photo_Temp & stToFile, stPath_Ols_Photo & stToFile
Else
inCnt = 1
If Dir(stPath_Ols_Photo & stToFile & ".old" & inCnt) = "" Then
Name stPath_Ols_Photo & stToFile As stPath_Ols_Photo & stToFile & ".old" & inCnt
Else
Do While Dir(stPath_Ols_Photo & stToFile & ".old" & inCnt) <> ""
inCnt = inCnt + 1
Loop
Name stPath_Ols_Photo & stToFile As stPath_Ols_Photo & stToFile & ".old" & inCnt
End If
FileCopy stPath_Ols_Photo_Temp & stToFile, stPath_Ols_Photo & stToFile
End If
Kill stPath_Ols_Photo_Temp & stToFile
End If
frmSubjectMaint.lblNoPhoto.Caption = ""
frmSubjectMaint.imgPhoto.Picture = LoadPicture(stPath_Ols_Photo & stToFile)
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 52
Call subErrorRoutine("There is no disk in the specified drive. Do you want to upload from a floppy diskette?.", 4)
If inUserResponse = vbYes Then
Resume
Else
frmSubjectMaint.CommonDialog1.InitDir = st_MYCOMPUTER_CLSID
Resume Next
End If
Case 58
'Already on file
Resume Next
End Select
End Sub
|
|
|
|
|
You could use the VB.NET OpenFileDialog; there was a toolpack aimed at those who have to migrate from VB6 to VB.NET, that also showed how to call .NET code from VB6.
Alternatively, you could build one from scratch.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
We aren't using VB.NET for this. Otherwise we would just convert the entire program to VB.NET. How would you suggest I "build one from scratch".
|
|
|
|
|
Liefie2000 wrote: We aren't using VB.NET for this I know; the suggestion would be to extend your application using some other language than VB6.
Liefie2000 wrote: How would you suggest I "build one from scratch". The same way any form is built in VB6. That's what the dialog is, just another form with textboxes and buttons.
You're welcome btw
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
When an row in a ListBox is selected, it is highlighted a nice deep blue.
If that ListBox loses focus, the ListBox's selected row remains highlighted in blue.
However, when a ListView loses focus (and it's HideSelection property is set to false), although the selected rows remain highlighted, the highlight is no longer a nice deep blue but rather a barely visible light grey.
Is there a way to change the highlighted color of ListView's selected row when the ListView no longer has focus?
Thanks,
Jim Dolson
|
|
|
|
|
The control is using the system colors to paint itself.
If you want to change the colors it's using, you'll have to paint the control yourself. C# Custom Paint ListView[^]
|
|
|
|
|
In addition to Dave's answer, it's usually not worth the effort. Unless you use the highlight-color as defined in the system-colors, your blue would default to red on my desktop
If it's merely to get consistency then do consider the fact that you are adding code that might throw exceptions/have bugs, while the only advantage is color-consistency (one that is still a non-default, and hence, unexpected)
If you are letting the user make a selection, then you could consider using checkboxes to indicate the selection.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you gentlemen. I've decided to leave the default behavior alone.
Jim
|
|
|
|
|
Hello !
I'm using Vb.net 2013 , Entity Framework , SQL Server 2008R2 and SMO.
I want to disconnect from database and set offline.
I try this code using SMO:
conn = New ServerConnection()
conn.ServerInstance = serverName
srv = New Server(conn)
Dim db As Database
db = srv.Databases(databaseName)
db.setoffline
But the problem is that the application hang on the last line and doesn't respond.
Is there anything that I should do with entity framework before set the database offline ?
Thank you !
|
|
|
|