|
Hello!
I'm an MS Access veteran making the jump to SQL/VB database apps. I must admit I'm struggling a bit with .Net, I never fancied myself as much of a programmer.
Anywho, my problem is this: How do I emulate the use of subforms with VB.net? In Access, my practice was to use 1 form as a db desktop of sorts, with all nav components on the left, and a subform utilizing the rest of the space. I would change the source of the subform based on the users nav choice.
What is the recommended practice to accomplish this in .net?
|
|
|
|
|
Forms works very differently in Access then they do in VB/C#/C++. There is no such thing as a subform and there is no such thing as changing the datasource of a form.
You have to make the forms up yourself, usually one for each option you want. Then show the appropriate form for your picked option and setup the datasources for the controls on that form.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have the need to use a specific program to display documents, whether they be text, documents, tiff files, whatever. How can I find the installation location of this program and use that to start the process? I cant guarantee that the software will always be installed at C:\Program Files\Program\Program.exe. I know this is done many times with programs because I've installed some myself that look for other installs I just dont know how it is done.
Thanks,
Cleako
|
|
|
|
|
There's no one method that works for every single app. Each app is going to either record this information, most likely in a different place in the Registry, or not record it at all and you'll have to search the hard drive for the .EXE, which is not that common now-a-days.
In the registry, you can try looking under the key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
for the app that you want. You'll need to know it's GUID to find it under here. The GUID will be the same on every machine for each application component version. Under there, you can check for a InstallLocation value which should give you the path that the app was installed to, but not always!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Well why wouldnt I have thought of that? Thanks!
|
|
|
|
|
I would like to know if anyone knows how to access context sensitive help from a help collection from VB. Is it a call to the HTMLHelp API interface or to hh.exe? I have tried to search for help on the web but got nowhere.
I know that I can create an XML help collection file listing all of the CHMs that I want to group into a help file and then include a reference to this .COL file in the hhcolreg.dat file. By creating a shortcut, I am able to open up my linked collection of help files. However, what I really want to do is access the collection from a VB project and open it up directly on a topic of choice in any of the included CHM files.
If anyone knows how to do this then please let me know ASAP.
Laura
|
|
|
|
|
Where do you get the error message?
That error message has nothing to do with the code that you are showing. It comes from a class that have the value, minimum and maximum properties. It sounds like something like a progress bar.
---
b { font-weight: normal; }
|
|
|
|
|
![Go to Parent](https://www.codeproject.com/App_Themes/CodeProject/Img/arrow-up24.png) totally true, I have a progress bar.
this is the code I have:
Private Sub Form_Initialize()<br />
InitCommonControls()<br />
End Sub<br />
Private Delegate Function CopyProgressRoutine(ByVal totalFileSize As Int64, ByVal totalBytesTransferred As Int64, ByVal streamSize As Int64, ByVal streamBytesTransferred As Int64, ByVal dwStreamNumber As Int32, ByVal dwCallbackReason As Int32, ByVal hSourceFile As Int32, ByVal hDestinationFile As Int32, ByVal lpData As Int32) As Int32<br />
<br />
Private Declare Auto Function CopyFileEx Lib "kernel32.dll" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal lpProgressRoutine As CopyProgressRoutine, ByVal lpData As Int32, ByVal lpBool As Int32, ByVal dwCopyFlags As Int32) As Int32<br />
Private _totalFileSize As Long = 0<br />
Private _totalBytesCopied As Long = 0<br />
Private _copyProgressRoutine As CopyProgressRoutine<br />
Private Source, Source2, Source3, Source4 As String<br />
Dim UserProfileName = SystemInformation.UserName<br />
<br />
<br />
Private Destination As String = "H:\Documents and Settings\" & UserProfileName<br />
<br />
Dim frmProgBar As New frmProgBar<br />
<br />
<br />
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click<br />
<br />
Me.Close()<br />
Dim fbdBrowse As New FolderBrowserDialog<br />
If fbdBrowse.ShowDialog() = DialogResult.OK Then<br />
<br />
Source = fbdBrowse.SelectedPath<br />
Source2 = Source & "\" & "My Documents"<br />
'Source3 = fbdBrowse.SelectedPath & "\Desktop"<br />
'Source4 = fbdBrowse.SelectedPath & "\Favorites"<br />
Else : End<br />
<br />
End If<br />
<br />
If (MessageBox.Show("You have chosen to copy all files and folders from: " & Chr(13) & Source & Chr(13) & "to: " & Chr(13) & Destination, "Data Mover", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) = DialogResult.OK) Then<br />
<br />
<br />
frmProgBar.Show()<br />
<br />
GetTotalFileSize(New System.IO.DirectoryInfo(Source2))<br />
_copyProgressRoutine = New CopyProgressRoutine(AddressOf CopyProgress)<br />
CopyFiles(New System.IO.DirectoryInfo(Source), Destination)<br />
MessageBox.Show("Data move done, make sure that the user doesn't have custom folders on d:\ or c:\", "Data Mover", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)<br />
<br />
Else<br />
MessageBox.Show("Action Canceled", "Data Mover", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)<br />
<br />
End If<br />
<br />
<br />
End<br />
<br />
End Sub<br />
<br />
Public Function CopyDirectory(ByVal Src As String, ByVal Dest As String, Optional _<br />
ByVal bQuiet As Boolean = False) As Boolean<br />
If Not Directory.Exists(Src) Then<br />
Throw New DirectoryNotFoundException("The directory " & Src & " does not exists")<br />
End If<br />
If Directory.Exists(Dest) AndAlso Not bQuiet Then<br />
If MessageBox.Show("directory " & Dest & " already exists." & vbCrLf & _<br />
"If you continue, any files with the same name will be overwritten", _<br />
"Continue?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, _<br />
MessageBoxDefaultButton.Button2) = DialogResult.Cancel Then Exit Function<br />
End If<br />
<br />
'add Directory Seperator Character (\) for the string concatenation shown later<br />
'If Dest.Substring(Dest.Length - 1, 1) <> Path.DirectorySeparatorChar Then<br />
' Dest += Path.DirectorySeparatorChar<br />
' End If<br />
If Not Directory.Exists(Dest) Then Directory.CreateDirectory(Dest)<br />
Dim Files As String()<br />
Files = Directory.GetFileSystemEntries(Src)<br />
Dim element As String<br />
For Each element In Files<br />
If Directory.Exists(element) Then<br />
'if the current FileSystemEntry is a directory,<br />
'call this function recursively<br />
CopyDirectory(element, Dest & Path.GetFileName(element), True)<br />
Else<br />
'the current FileSystemEntry is a file so just copy it<br />
File.Copy(element, Dest & Path.GetFileName(element), True)<br />
End If<br />
Next<br />
Return True<br />
End Function<br />
Private Function CopyProgress(ByVal totalFileSize As Int64, ByVal totalBytesTransferred As Int64, ByVal streamSize As Int64, ByVal streamBytesTransferred As Int64, ByVal dwStreamNumber As Int32, ByVal dwCallbackReason As Int32, ByVal hSourceFile As Int32, ByVal hDestinationFile As Int32, ByVal lpData As Int32) As Int32<br />
frmProgBar.ProgressBar1.Value = Convert.ToInt32((_totalBytesCopied + totalBytesTransferred) / _totalFileSize * 100)<br />
Application.DoEvents()<br />
End Function<br />
Private Sub GetTotalFileSize(ByVal folder As System.IO.DirectoryInfo)<br />
For Each fi As System.IO.FileInfo In folder.GetFiles<br />
_totalFileSize += fi.Length<br />
Next<br />
For Each di As System.IO.DirectoryInfo In folder.GetDirectories<br />
GetTotalFileSize(di)<br />
Next<br />
End Sub<br />
Private Sub CopyFiles(ByVal folder As System.IO.DirectoryInfo, ByVal destinationFolder As String)<br />
If Not System.IO.Directory.Exists(destinationFolder) Then<br />
System.IO.Directory.CreateDirectory(destinationFolder)<br />
End If<br />
For Each fi As System.IO.FileInfo In folder.GetFiles<br />
CopyFileEx(fi.FullName, destinationFolder & "\" & fi.Name, _copyProgressRoutine, 0, 0, 0)<br />
_totalBytesCopied += fi.Length<br />
Next<br />
For Each di As System.IO.DirectoryInfo In folder.GetDirectories<br />
CopyFiles(di, di.FullName.Replace(Source, Destination))<br />
Next<br />
End Sub<br />
<br />
<br />
End Class
it's the value which is integer I guess and should be converted to something else.
thanks for the quick response btw.
Do you know what I'm doing wrong?
Greetzzz,
CornElvis
www.jackied.nl
-- modified at 9:25 Friday 16th June, 2006
|
|
|
|
|
Could you paste just the relevant code instead of the entire application?
---
b { font-weight: normal; }
|
|
|
|
|
Progressbar1.maximum = 101 (or more)
|
|
|
|
|
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.ArgumentOutOfRangeException: Value of '101' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.
Parameter name: Value
at System.Windows.Forms.ProgressBar.set_Value(Int32 value)
at WindowsApplication1.Form1.Timer1_Tick(Object sender, EventArgs e)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
WindowsApplication1
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Documents%20and%20Settings/Owner/My%20Documents/Downloads/Compressed/hack/Top_Eleven_Hack_v.4.6_64-bit.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 10.0.0.0
Win32 Version: 10.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitdebugging="true">
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
|
|
|
|
|
Does VB controls support Unicode ? If yes how wothout using Microsoft Forms 2.0.
Jyoti
|
|
|
|
|
I'm assuming you're talking about VB6 or VBA. Yes, all strings in VB6 are BSTR's, which supports Unicode.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I need to ping a system and need check the result (Reply from or Request Time Out)
so i used CreateObject("WScript.Shell")
but this does not run on Win 2000
This is the error i am getting
"System.MissingMemberException: Public member 'Exec' on type 'IWshShell2' not found. at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)"
I need a function which can run on any win OS.
Need help urgently
the function i am using
Dim strComputer As String = IP
Dim objShell = CreateObject("WScript.Shell")
Dim objScriptExec = objShell.Exec("ping -n 2 -w 100 " & strComputer)
Dim strPingResults = LCase(objScriptExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
else
end if
-- modified at 6:50 Friday 16th June, 2006
|
|
|
|
|
Why are you using Windows Scripting when you can do the exact same thing using the .NET Frameworks Process[^] class?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
objective: to draw a flow chart by drag and drop buttons or anything. but the flow chart must be created only by drag and drop. Does anyone know how to do it..if you have any examples please send them.
KIRAN PINJARLA
|
|
|
|
|
:Sniff: :Sniff:
I detect the scent of homework in this request for pre-written code.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi everyone. Please assist me. i wish to view my numeric data from a mschart. am using msaccess for database where i have a table know as dbscore. the name of the table is tblscore, with two fields, name and achievements. under achievement against each name are numeric value that i wish to view using MSChart. am using ADODC connector. how do i go about it + its coding?
Still learning
|
|
|
|
|
|
I have problem with mdiChild. Question
In mdiCHild i used MenuStrip with some item, when i run it the items go to mdiparent but Menustrip still in mdichild.
detail
www.khmerfriend.com/ViewKWFullInterface
................
|
|
|
|
|
|
In VB6 to view values on the Debug window all you done was debug then the variable.
How do you do this on vb.net?
I have tried Debug.WriteLine("Number is: ") but this does not appear in the option debug\windows\immediate
I must be doing something stupid.
Thanks in advance.
|
|
|
|
|
directred wrote: I have tried Debug.WriteLine("Number is: ") but this does not appear in the option debug\windows\immediate
According to your code, you didn't concatenate any variable. It should be:
Debug.WriteLine("Number is: " & VariableName)
|
|
|
|
|
use
Debug.Print("My String to print on the immediate window")
|
|
|
|
|
This seem to be a function in vb6?
|
|
|
|
|