|
Thanks for replay.
However, I tried Application.DoEvents(), but I need some function like Thread.Sleep to add delay between Paint Event and Measure(). Otherwise, I still have Measure() happened too fast before Paint Event finished displaying image. Please advise. Thank you.
PanelPG.Invalidate()
t1 = VB.Timer
Do While VB.Timer < t1 + 1
Application.DoEvents()
Loop
Measure ()
|
|
|
|
|
Simple. Insert the Sleep line after the DoEvent line.
I just re-read your code. Putting the Sleep line in this code will stop the UI thread and keep the Paint messages from being processed. You can't put the Sleep line in here at all.
Without seeing the rest of this code, what measure does, and what you want this to do, it's impossible to tell you exactly what to do to fix this. Alot of this problem appears to be comming down to a design problem.
|
|
|
|
|
Hi, Dave:
Thank you very much for your response. I finally got it working after applying two sleep function before and after Measure(). This is somewhat not very efficient. But additional delay gives me a work application at least.
Steven
modified on Monday, December 10, 2007 5:50:01 PM
|
|
|
|
|
I'm unclear how to get control again of a .dll after unloading the domain. I thought the unload would free the file, but it does not seem to. the final line here does not allow the file delete. How do I release it?
Thanks in advance!
Dim SubDomain = AppDomain.CreateDomain("New Domain")
Dim as1 As Assembly = Reflection.Assembly.ReflectionOnlyLoadFrom("MA.dll")
Dim IndicatorClass = SubDomain.CreateInstanceAndUnwrap as1.FullName, "Indicators.Indicator")
AppDomain.Unload(SubDomain)
File.Delete("MA.dll")
|
|
|
|
|
You don't. It'll stay locked so long as your app is running, even if you're not using the code in the .DLL, it's still loaded into your process. There is no way to release the lock without unloading your app.
Why would you want to delete a .DLL anyway??
|
|
|
|
|
My idea is (was?):
1. Load the .dll into a new, separate app and use it.
2. Unload the separate app, allowing the user to edit the .dll (through VBCodeProvider)
3. Reload the new, edited .dll into the separate app.
Honestly, I thought that was the whole idea of the separate app created with CreateDomain -- to allow the user flexibility over loading and unloading apps while keeping the main app running. Have I missed something, or am I not doing this the right way?
|
|
|
|
|
I am using a binding source and when I assign the binding source to a dataTable I get an error that says I used the variable "bsMonStoreSched" before assigning it a value, a green line shows up under the binding Source.
Here is my code. Is there something I am doing wrong?
Also, can I use a single binding source instead of using a different binding source for each item I filter?
If you notice below I used the same dataTable and assigned it to multiple binding sources. Can I do this with one binding source?
Here is the code.
' declare variables<br />
Dim bsMonStoreSched As BindingSource<br />
Dim bsTuesStoreSched As BindingSource<br />
<br />
' create table adapter objects<br />
Dim hoursTableAdapter As New DataSetTableAdapters.tbl_hoursTableAdapter<br />
Dim schedTableAdapter As New DataSetTableAdapters.tbl_store_schedTableAdapter<br />
<br />
' create data set objects<br />
Dim lpDataSet As New DataSet()<br />
<br />
' create dataTables<br />
Dim dtHours, dtSched As New DataTable()<br />
<br />
' fill the dataTables<br />
Try<br />
hoursTableAdapter.Fill(lpDataSet.tbl_hours)<br />
schedTableAdapter.Fill(lpDataSet.tbl_store_sched)<br />
Catch err As Exception<br />
MessageBox.Show(err.Message)<br />
End Try<br />
<br />
dtHours = lpDataSet.tbl_hours<br />
dtSched = lpDataSet.tbl_store_sched<br />
<br />
' Set the binding Source for mon - tues<br />
bsMonStoreSched.DataSource = dtSched ' The green line shows up here<br />
bsTuesStoreSched.DataSource = dtSched<br />
<br />
' Filter the items to show results.<br />
bsMonStoreSched.Filter = "ss_day='Monday'"<br />
bsTuesStoreSched.Filter = "ss_day='Tuesday'"
|
|
|
|
|
You did exactly what the error said you did. You declared two variables that don't point to actual objects of type BindingSource. Depending on what this code is really supposed to be doing, the error is saying that you need to change the first two lines in this snippet to:
' declare variables
Dim bsMonStoreSched As New BindingSource()
Dim bsTuesStoreSched As New BindingSource()
I really doubt you'd be doing this in a method then abandoning the bindingsources. It would appear the you're actually trying to use bindingsources that you already have in your form, in which case, you wouldn't need the first two lines of code, but you would have to change the two lines where the squiggles show up, and the lines thereafter, to use the names of the bindingsources you already have on the form.
|
|
|
|
|
I am calling the binding source programatically instead of dragging and dropping the binding source and table adapter into the forms. When I was using the designer to create the binding source, data table and table adapter the forms designer was generating code that caused the desginer to not show up.
|
|
|
|
|
I need to execute a query to a table names tbl_store_sched where if the table column ss_day has a row that has Monday in it then the monday checkbox will get checked and the selected value for a combo box will be the same as the column ss_from. The combo box is populated from tbl_hours.
I figured I would use the tableAdapter.FillByTableColumn method but when I write the code the words fillBy end up with a blue line under them.
Is the TableAdapter.FillBy method the best way to do this?
Is there a way to just get all the results from the database table and then check those results to see if the rows exist or what information is in the row?
Can I just fill the dataTable using schedTableAdapter.Fill(lpDataSet.tbl_store_sched) and then get the results from certain rows and columns?
I will need to use data from this table for several checkboxes and combo boxes and I don't want to have to execute multiple queries.
|
|
|
|
|
You're getting the quiggly line because your tableadapter doesn't have a method called FillBySomething. You have to right-click the methods in dataset designer and click "Add Query...", supplying the SQL statement and options to generate the FillBy... method code.
|
|
|
|
|
Would it be better for me do a bunch of fillBy Methods or to use a binding source?
Wouldn't it slow my program down to do a bunch of FillBy Methods, being that each time I do it is represents a database query?
I have about 14 different combo boxes that all populate from the hours table. The difference between them is that when the user chooses a time in the combbo box they each store that time in the database and then when the user navigates to the store schedule tab the value that was stored in the database is the selected value in the combo box.
Here is tbl_store_sched
create table tbl_store_sched (<br />
ss_id int NOT NULL IDENTITY(51000,1),<br />
store_id int,<br />
ss_day text,<br />
ss_from text,<br />
ss_to text,<br />
primary key(ss_id),<br />
foreign key(store_id) references tbl_store(store_id));
If the user checks the Monday check box. They then will proceed to select a from time and a to time. Once they do this the day "Monday" is stored in the column ss_day and the from and to time are stored in ss_from and ss_to.
|
|
|
|
|
AAGTHosting wrote: Would it be better for me do a bunch of fillBy Methods or to use a binding source?
That depends on what your app does and the design of your app. Noone can tell you either way.
AAGTHosting wrote: Wouldn't it slow my program down to do a bunch of FillBy Methods, being that each time I do it is represents a database query?
If this is what your business rules require, then yes, you put these in.
AAGTHosting wrote: I have about 14 different combo boxes that all populate from the hours table. The difference between them is that when the user chooses a time in the combbo box they each store that time in the database and then when the user navigates to the store schedule tab the value that was stored in the database is the selected value in the combo box.
Here is tbl_store_sched
As for the rest, it looks like you really need to rethink how you're storing data in your tables. If a column is storing only the day of the week, you really don't want to do it using the full name of the day. A number field would do it and take up far less space in the database. Also, you're storing times as string in the database - wrong. Store them as time values, not strings. This will make data retrieval much easier and you'll avoid weird results with sorting and functions.
|
|
|
|
|
If I am going to store a time such as 3:00PM in the database and store it as a time not as a string, should I be using a date time picker? As far as I know the date time picker will not do time only. Right now I am using a combo box that has a list of times to choose from.
Greg
|
|
|
|
|
That doesn't change the fact that you're making a big mistake storing time values as strings in the database.
|
|
|
|
|
Initial Problem:
When Imaging numerous computers, they use the same SigmaTel device - and the DeviceID is the same. However, each different model MUST use a different driver version or the SigmaTel sound driver will not function. (That's messed up! - who wrote these Gateway model drivers!)
So... we're trying to develop a script that recognizes/pulls the DeviceID and Model, then depending on what computer model and DeviceID is found, then the correct driver should be loaded.
The VBS problem: The IF statements do not seem to be reading in the string variables (the objItem.Name). It does not seem to read it and is blank.
Anyone have any suggestions / solutions on this one! Any help is appreciated.
======Code:
On Error Resume Next
strComputer = "."
strName = objItem.Name
Dim objFSO ' File System Object
Dim objShell ' Window Shell Object
Dim ObjExec ' Execute command in Shell
Dim strResult ' Output from command execution
Dim strDeviceID ' Device ID of whatever we've found
Dim strDeviceIDShort ' Four-digit ID of device
Dim strDeviceIDLong
Dim strDeviceDesc ' Text description of device
Dim intNumDevices ' Just in case there's more than one, we'll want to know
Dim arrTemp
Dim strTemp
Dim Counter
Dim strComputers ' Computers this might be
Dim strINFFile ' What INFFile we're going to use
Set objShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystemProduct",,48)
'For Each objItem in colItems
'WScript.Echo "whois:" & objItem.Name
'Next
Wscript.Echo
Wscript.Echo "Looking for unconfigured High-Definition Audio Device..."
Wscript.Sleep 500
set objExec = objShell.Exec("c:\windows\devcon find *HDAUDIO\*")
strResult = objExec.StdOut.ReadAll
if InStr(strResult, "device(s)") <> 0 then
arrTemp = Split(strResult, vbcrlf)
If UBound(arrTemp) > 2 then
For Counter = 0 to (UBound(arrTemp) - 1)
If InStr(arrTemp(Counter), "Audio") <> 0 then
strTemp = arrTemp(Counter)
End if
If InStr(UCase(arrTemp(Counter)), "FOUND") <> 0 then
intNumDevices = CInt(Left(arrTemp(Counter), 1))
End if
Next
Else
strTemp = arrTemp(0)
intNumDevices = CInt(Left(arrTemp(1), 1))
End if
arrTemp = Split(strTemp, ":")
strDeviceIDLong = arrTemp(0)
strDeviceDesc = Trim(arrTemp(1))
arrTemp = Split(strDeviceIDLong, "&")
strDeviceID = arrTemp(0)
strDeviceIDShort = Right(Mid(strDeviceIDLong, InStr(strDeviceIDLong, "DEV_"), 8), 4)
Wscript.Echo "Found " & intNumDevices & " Hi-Def Audio Device(s)."
Wscript.Echo "Gathering information..."
Wscript.Echo
Else
Wscript.Echo "There are no Hi-Def Audio Devices present in the system."
Wscript.Echo "Exiting..."
wscript.Sleep 200
End if
For Each objItem in colItems
Select Case strDeviceIDShort
Case "7680"
strComputers = "Gateway E-4500, E-6610"
If objItem.Name = "E-6610D" then
strINFFile = "C:\Drivers\060Audio\010Sigmatel\070AC97\sthda.inf"
ElseIf objItem.Name = "E-6610" then
strINFFile = "C:\Drivers\060Audio\010Sigmatel\070AC97\sthda.inf"
ElseIf objItem.Name = "E4500" then
strINFFile = "C:\Drivers\060Audio\010Sigmatel\040AC97\sthda.inf"
ElseIf objItem.Name = "E-4500D" then
strINFFile = "C:\Drivers\060Audio\010Sigmatel\040AC97\sthda.inf"
End If
Case "7618"
strComputers = "Gateway E-4610, E-4610D"
strINFFile = "C:\Drivers\060Audio\010Sigmatel\040AC97\sthda.inf"
Case "7634"
strComputers = "Gateway M465, M685, E-100M"
strINFFile = "C:\Drivers\060Audio\010Sigmatel\020AC97\sthda.inf"
Case "7690"
strComputers = "Gateway E-475M, E-100M"
strINFFile = "C:\Drivers\060Audio\010Sigmatel\050AC97\sthda.inf"
Case Else
strComputers = "Unknown computer system"
strINFFile = "Not making any changes."
Wscript.Quit
End Select
Wscript.Sleep 350
Wscript.Echo "Driver Device ID: " & StrDeviceIDShort
Wscript.Echo "Device Description: " & strDeviceDesc
Wscript.Echo "System Device ID: " & strDeviceID
WScript.Echo
WScript.Echo "Possible Systems: " & strComputers
WScript.Echo "Device Driver to use: " & strINFFile
Wscript.Echo
Wscript.Echo "Attempting to update driver..."
WScript.Echo "whois:" & objItem.Name
Next
'WScript.Quit
Set objExec = objShell.Exec("c:\windows\devcon updateni " & strINFFile & " " & strDeviceID)
Wscript.Sleep 5000
strResult = objExec.StdOut.ReadAll
Wscript.Echo strResult
DFG
|
|
|
|
|
The problem could very easily be with WMI. Mmotherboard/machine/device manufacturers are not required to provide any information to WMI about the components. If they do, it's usually not complete information either. It's also entirely possible that some devices from a manufacturer will fill in some of the details and others won't fill in any at all.
|
|
|
|
|
WMI and the script appears to be capturing the name.
After looking at this a little bit further, it appears objItem.Name does not return a "text" string, therefore, our IF compare never produces a match.
Is there a way to get the return value to be read as a text string?
DFG
|
|
|
|
|
That depends on the object returned by Name. It should be a string, but could also be Nothing or some other object. The only way to attempt a conversion is to wrap it in a CStr() function call.
Dim name = CStr(objItem.Name)
|
|
|
|
|
How do I determine the output directory of a project (the place where temporary files are extracted)?
Many thanks!
|
|
|
|
|
Your question doesn't make any sense. A "projects" output, when compiled, ends up in the bin folder under your project's folder.
When an installer unpacks itself, the files can go either in a folder hard coded into the installer, or one of the Temp folders, like C:\TEMP, C:\TMP, C:\Windows\Temp, ...
What are you trying to do with this ability?? Is this code that's running in an installer as a custom action??
|
|
|
|
|
Change it in the project properties, it can dictate which folder the files are stored in, and you can set where you want the compiler to output the debug and exe files
|
|
|
|
|
This one really has me stuck. Like the subject says, I would like to open a word document that is an embedded resource in my vb.net application.
Up to now I have been able to open a new document with automation:
oDoc = oWord.Documents.Add
or open an existing doc on my hard drive:
oDoc = oWord.Documents.Open("path and filename")
I have little clue, however, how to successfully refer to an embedded document and open that with word automation. Ideally, I would like to do this without actually saving the embedded doc to the user's hard drive first (if possible).
Thanks for your help,
Craig
modified on Wednesday, December 05, 2007 11:45:43 AM
|
|
|
|
|
Can't be done. In order for Word to open the document, it MUST be a file on a drive. It does not have the ability to open a file from a resource, nor a .NET stream object.
The only way I could think of that simulates this, would be to come up with your own script that tells your code how to build a new Word document.
|
|
|
|
|
assuming a little different situation, but you´ll get the point:
picBox.Image = My.Resources.ResourceManager.GetObject("smq")
and for writing a ressource to a file:
Dim x() As Byte
Dim bw As New BinaryWriter(New FileStream("c:\fwd.doc", FileMode.CreateNew))
bw.Write(x)
modified on Wednesday, December 05, 2007 12:29:35 PM
|
|
|
|