|
Hi,
Can anyone guide me on how to generate a listbox from one listbox?
I have a listbox1 with items such as ( sale, buy). On listbox1_TextChanged, I want listbox2 to enlist items(Old metal iron, scrap metal iron) based on the conditions..
thanks in advance
|
|
|
|
|
What have you tried? You should be able to Clear the listbox2 's Items and Add new ones according to the value of listbox1 's Text .
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
waner michaud wrote:
On listbox1_TextChanged
You are using the wrong event. Its ListBox1_SelectionChanged.
Well i don't know what your program does and how do you get these:
waner michaud wrote:
items(Old metal iron, scrap metal iron)
well on the above event, use the ListBox1.SelectedItem to get the selected item in your listbox and then you use some function and pass ListBox1.SelectedItem like :dim myListofItems= getItems(ListBox1.SelectedItem)...define this function and give its return type as List and then do this:
for each myItem as String in myListOfitems
ListBox2.items.add(myItem)
end for
|
|
|
|
|
Hello,
I'm have a VB solution with 5 projects, and I'm using some third-party controls (from the same vendor) in these projects. I'm installing all of these projects to their own folder within a main folder.
Main project folder: C:\Program Files\App Suite
Project 1 - C:\Program Files\App Suite\Project 1
Project 2 - C:\Program Files\App Suite\Project 2
etc
When I compile the Windows installer, it tries to bring in the same DLL multiple times (once for each time we use it in a project).
What I want to do is install the Dlls to a 'Common Files' folder (C:\Program Files\Common Files\App Suite) and only have one copy of each DLL. I then want to have my 5 projects reference the shared DLLs from the common folder.
Does anyone know what I need to do to make this happen? What I want to avoid is having 5 copies of the same DLL. I just want to have my 5 projects reference the same DLL file.
Thanks in advance!
|
|
|
|
|
I'd start by scraping the Setup and Deployment projects and use a third party tool, such as InstallShield Express, InnoSetup, WIX, or whatever to create the installer. These tools will let you be far more flexible than the bare-bones basic Setup and Deployment project.
|
|
|
|
|
Hmm - so it sounds like there isn't a setting that would tell a project to look for DLLs in folders outside of the project hierarchy. That poses a problem. The solution is in VB.NET 2008 and I'm doing this in a government environment, so I'm subject to those constraints. We don't have InstallShield Express - just the native Windows installer options in Visual Studio 2008.
Originally, we were dropping all of the project outputs into a single folder (ex: C:\Program Files\App Suite), but the Setup project identified the same DLLs as dependencies multiple times (once for each project using the DLL). We've tried marking Exclude on the duplicates, but that seems like a workaround and not a real solution.
I'm assuming that if we did the Setup scraper, and used InstallShield Express, we'd also need to include code in each project to manually force the project to look in the Common File folder for the 'missing' DLLs.
Thanks for the help on this, Dave, et al. It is appreciated.
|
|
|
|
|
The problem with the Setup and Deployment project is that it's not really designed to support multiple projects or complex installations. I haven't used it in years, just because I needed to to more complex things in my setups, like what you're doing.
vvincent wrote: We've tried marking Exclude on the duplicates, but that seems like a workaround and not a real solution.
There's a bunch of little gotcha's in the S&D project like that.
vvincent wrote: I'm assuming that if we did the Setup scraper, and used InstallShield Express, we'd also need to include code in each project to manually force the project to look in the Common File folder for the 'missing' DLLs.
I've had to do that before. It's not very difficult at all, but you do have to put some custom code in to use the CommonFiles folder.
Basically, the AppDomain class exposes a AssemblyResolve event that can be used to manually load an assembly that fails to load because it wasn't in the normal assembly search chain. You can use then return the corrected path to where the assembly should be found. It's not much code at all.
You can play around with the example found here[^]. And there's a C# example here[^] in answer #2. It's badly formatted, but is easily cleaned up and translates directly to VB.NET.
|
|
|
|
|
Dave Kreskowiak wrote: vvincent wrote:
We've tried marking Exclude on the duplicates, but that seems like a workaround and not a real solution.
There's a bunch of little gotcha's in the S&D project like that.
That's the honest truth right there. Hence trying to find a better solution.
So it sounds like we'd need to use the AppDomain.AssemblyResolve event in each project's form (or wherever) and tell it to look in a specific folder location for any DLL that we're using on that form. Does that sound right? I'm hoping we can set this on a global level in the application (running this during the ApplicationEvents.StartUp event, for example) instead of each form.
This gives me something to work with, even if it's not what I was hoping for. Much thanks!
Vernon L. Vincent
|
|
|
|
|
Dave's advise is very good. After you have deployed your solution, maybe you will have some problems becouse your libraries will not be in the same location as your executable files. Here[^] is what you will need to deal with this situation.
|
|
|
|
|
I have a vb .net executable that contains references to a couple vb6 .dlls which have references to a videosoft vsflexgrid7.ocx control. This project/.exe works fine on WinXP boxes. When running on a Win7 client (regardless if x86 or 64), when a child form is called from one of the .dll references, the grid is missing.
I installed a VM env. with Win7 and put VS2005 on it. If I open the .sln and run the program through VS, everything is peachy. If I close VB and attempt to run the app through with the compiled files in the debug directory, the grids no longer show up.
I created a VB6 app to call the .dlls and ran that on the same Win7 client box and the grids show up fine (meaning the referenced .dll and .ocx references are valid).
Any idea what VS is doing behind the scenes to make the grids show up vs when running the app standalone? So confused!
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Just inquiring if anyone has any ideas to test with this? still stuck and not sure what to do.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Hi all,
I have a vb.net application and I want to publish it to only one user for testing purpose.
What are the ways to do it?
Thanks in advance.
|
|
|
|
|
0) Really Complex way : use hardware dongles to control access. e.g. Aladdin HASP or DesKey etc.
1) Complex way : You could implement a key validation mechanism via the internet. Issue the key to the user, and then when you don't want to them to use it anymore, invalidate the key. Also, limit the activation count against the key to restrict further distribution.
2) Medium way : publish to a location that they only know, and require username and passowrd to access, wouldn't prevent further distribution once they have it.
3) simple way : work on trust and / or NDA agreements in place
4) really simple way, just give them the software and tell them not to share / is it really worth that much to go to all the hassle of #0, #1, #2 or #3
|
|
|
|
|
Thanks a lot for the reply.
Will try to use any one of the above mentioned ways.
|
|
|
|
|
Hello,
I am working on timeout web security function for my project.
I am using a web message box to display messages in web when the time elapsed.
The System.Timers.Timer function can work well at web, except the part where it calls the WebMsgBox from event.
Full coding as below :
<br />
Partial Class _Default<br />
Inherits System.Web.UI.Page<br />
Public aTimer_A As New System.Timers.Timer()<br />
<br />
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<br />
AddHandler aTimer_A.Elapsed, AddressOf OnTimedEvent<br />
aTimer_A.Interval = 5000<br />
aTimer_A.Enabled = True<br />
WebMsgBox("Page loaded - can come out")<br />
End Sub<br />
<br />
Public Sub OnTimedEvent(ByVal source As Object, ByVal e As Timers.ElapsedEventArgs)<br />
WebMsgBox("OnTimedEvent - does not come out")<br />
End Sub<br />
<br />
Public Sub WebMsgBox(ByVal sMsg As String)<br />
Try<br />
Dim sb As New StringBuilder()<br />
Dim oFormObject As System.Web.UI.Control<br />
<br />
sMsg = sMsg.Replace("'", "\'")<br />
sMsg = sMsg.Replace(Chr(34), "\" & Chr(34))<br />
sMsg = sMsg.Replace(vbCrLf, "\n")<br />
sMsg = "<script language=javascript>alert(""" & sMsg & """)</script>"<br />
sb = New StringBuilder()<br />
sb.Append(sMsg)<br />
<br />
For Each oFormObject In Me.Controls<br />
If TypeOf oFormObject Is HtmlForm Then<br />
Exit For<br />
End If<br />
Next<br />
<br />
oFormObject.Controls.AddAt(oFormObject.Controls.Count, New LiteralControl(sb.ToString()))<br />
Catch ex As Exception<br />
<br />
End Try<br />
End Sub<br />
End Class<br />
<br />
Please advise. Your guidance on solving this problem is very much appreciated.
Thanks,
Goutam
|
|
|
|
|
If understand what you want to do, it appears as though you're trying to get a messagebox to pop up on the users browser using a timer event on the server. This cannot work because the server cannot initiate a connection to the client. The message box won't show up until the browser refreshes the page and even then, with your design, I'm not sure that's going to happen even then.
|
|
|
|
|
Thank you. Your explanation clarified a lot of things.
Now, I am trying to solve the problem at client side itself, with javascript, using below sample codes:
http://stackoverflow.com/questions/572938/force-logout-users-if-users-are-inactive-for-a-certain-period-of-time
|
|
|
|
|
hi i wish to check if the format i use for checkbox is it correct?
<pre lang = 'vb'>Imports System.Speech.Synthesis
Public Class Form1
Dim FromSerialPort1 As String
Dim XX(100) As Integer
Dim YY(100) As Integer
Dim ZZ(100) As Integer
Dim Flag As Integer
Dim Speaker_Flag As Integer = 0
Dim FromSerialPort_Temp
Dim Thermistor_Temp(15) As Integer
Dim Thermistor_R(15) As Integer
Dim Circuit_Thermistor_R As Double
Dim Result
Dim Counter As Integer
Dim Temperature_low
Dim Temperature_high
Dim Resistance_low
Dim Resistance_high
Dim Rnum1
Dim Rnum2
Dim Speaker As New SpeechSynthesizer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TimerSpeak2.Enabled = True
TimerTemp.Enabled = True
Private Sub ReadSerialPortForTemp()
FromSerialPort_Temp = SerialPortTemp.ReadExisting
If Len(FromSerialPort_Temp) <> 0 Then
TextBoxVoltage.Text = 0.01 * Convert.ToInt16(FromSerialPort_Temp.SubString(2, 3), 16)
Else
FromSerialPort_Temp = "U1000"
End If
End Sub
Private Sub OpenPort1()
If SerialPortTemp.IsOpen Then
SerialPortTemp.Close()
End If
SerialPortTemp.PortName = "Com4"
SerialPortTemp.BaudRate = 9600
SerialPortTemp.Parity = System.IO.Ports.Parity.None
SerialPortTemp.DataBits = 8
SerialPortTemp.StopBits = System.IO.Ports.StopBits.One
SerialPortTemp.RtsEnable = True
SerialPortTemp.Open()
End Sub
Private Sub ThermistorTable()
Thermistor_Temp(0) = -10
Thermistor_R(0) = 42506
Thermistor_Temp(1) = -5
Thermistor_R(1) = 33892
Thermistor_Temp(2) = 0
Thermistor_R(2) = 27219
Thermistor_Temp(3) = 5
Thermistor_R(3) = 22021
Thermistor_Temp(4) = 10
Thermistor_R(4) = 17926
Thermistor_Temp(5) = 15
Thermistor_R(5) = 14674
Thermistor_Temp(6) = 20
Thermistor_R(6) = 12081
Thermistor_Temp(7) = 25
Thermistor_R(7) = 10000
Thermistor_Temp(8) = 30
Thermistor_R(8) = 8315
Thermistor_Temp(9) = 35
Thermistor_R(9) = 6948
Thermistor_Temp(10) = 40
Thermistor_R(10) = 5834
Thermistor_Temp(11) = 45
Thermistor_R(11) = 4917
Thermistor_Temp(12) = 50
Thermistor_R(12) = 4161
Thermistor_Temp(13) = 55
Thermistor_R(13) = 3535
Thermistor_Temp(14) = 60
Thermistor_R(14) = 3014
Thermistor_Temp(15) = 1000
Thermistor_R(15) = 1
For Counter = 0 To 15
If CInt(TextBoxResistance.Text) >= Thermistor_R(Counter) Then
If Counter <> 0 And Counter <> 15 Then
Temperature_high = Thermistor_Temp(Counter)
Temperature_low = Thermistor_Temp(Counter - 1)
Resistance_low = Thermistor_R(Counter)
Resistance_high = Thermistor_R(Counter - 1)
Rnum1 = Resistance_high - TextBoxResistance.Text
Rnum2 = Resistance_high - Resistance_low
Result = 2.5 + Math.Round(Temperature_low + (5 * Rnum1 / Rnum2), 1)
TextBoxTemp.Text = Result & "C"
Exit For
If Counter = 0 Or Counter = 15 Then
TextBoxTemp.Text = "Out Of Range"
Exit For
End If
End If
End If
Next
End Sub
Private Sub TimerTemp_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerTemp.Tick
Call OpenPort1()
TextBoxVoltage.Clear()
TextBoxResistance.Clear()
TextBoxTemp.Clear()
SerialPortTemp.WriteLine("U1" + vbCr)
System.Threading.Thread.Sleep(150)
Call ReadSerialPortForTemp()
If Len(TextBoxVoltage.Text) = 0 Then
Else
Circuit_Thermistor_R = 10000 * TextBoxVoltage.Text / (5 - TextBoxVoltage.Text)
TextBoxResistance.Text = Math.Round(Circuit_Thermistor_R, 0)
Call ThermistorTable()
End If
End Sub
Private Sub TimerSpeak2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerSpeak2.Tick
Call ThermistorTable()
If CheckBox1.Checked = True Then //from this part
Call ThermistorTable()
If Result >= 0 Then
TextBox.Text = ""
TextBox.Text = "Your Temperature is" + "" + TextBoxTemp.Text
TextBox.Refresh()
Speaker.Speak(TextBox.Text)
End If //to this part
</pre>
|
|
|
|
|
Just a glance and I can see there are a lot of things to improve here. Anyhow, I can see you have tried and worked on it, and that is much more than what we are used to see. Edit your question and repair the <pre> tag. Then I will tell you what you should improve.
|
|
|
|
|
currrently my thermistor is able to capture temperature however after i click on checkbox1 it display Conversion from string "" to type 'Integer' is not valid please advise thanks
Imports System.Speech.Synthesis
Public Class Form1
Dim FromSerialPort1 As String
Dim XX(100) As Integer
Dim YY(100) As Integer
Dim ZZ(100) As Integer
Dim Flag As Integer
Dim Speaker_Flag As Integer = 0
Dim FromSerialPort_Temp
Dim Thermistor_Temp(15) As Integer
Dim Thermistor_R(15) As Integer
Dim Circuit_Thermistor_R As Double
Dim Result
Dim Counter As Integer
Dim Temperature_low
Dim Temperature_high
Dim Resistance_low
Dim Resistance_high
Dim Rnum1
Dim Rnum2
Dim Speaker As New SpeechSynthesizer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TimerSpeak2.Enabled = True
TimerTemp.Enabled = True
Private Sub ReadSerialPortForTemp()
FromSerialPort_Temp = SerialPortTemp.ReadExisting
If Len(FromSerialPort_Temp) <> 0 Then
TextBoxVoltage.Text = 0.01 * Convert.ToInt16(FromSerialPort_Temp.SubString(2, 3), 16)
Else
FromSerialPort_Temp = "U1000"
End If
End Sub
Private Sub OpenPort1()
If SerialPortTemp.IsOpen Then
SerialPortTemp.Close()
End If
SerialPortTemp.PortName = "Com4"
SerialPortTemp.BaudRate = 9600
SerialPortTemp.Parity = System.IO.Ports.Parity.None
SerialPortTemp.DataBits = 8
SerialPortTemp.StopBits = System.IO.Ports.StopBits.One
SerialPortTemp.RtsEnable = True
SerialPortTemp.Open()
End Sub
Private Sub ThermistorTable()
Thermistor_Temp(0) = -10
Thermistor_R(0) = 42506
Thermistor_Temp(1) = -5
Thermistor_R(1) = 33892
Thermistor_Temp(2) = 0
Thermistor_R(2) = 27219
Thermistor_Temp(3) = 5
Thermistor_R(3) = 22021
Thermistor_Temp(4) = 10
Thermistor_R(4) = 17926
Thermistor_Temp(5) = 15
Thermistor_R(5) = 14674
Thermistor_Temp(6) = 20
Thermistor_R(6) = 12081
Thermistor_Temp(7) = 25
Thermistor_R(7) = 10000
Thermistor_Temp(8) = 30
Thermistor_R(8) = 8315
Thermistor_Temp(9) = 35
Thermistor_R(9) = 6948
Thermistor_Temp(10) = 40
Thermistor_R(10) = 5834
Thermistor_Temp(11) = 45
Thermistor_R(11) = 4917
Thermistor_Temp(12) = 50
Thermistor_R(12) = 4161
Thermistor_Temp(13) = 55
Thermistor_R(13) = 3535
Thermistor_Temp(14) = 60
Thermistor_R(14) = 3014
Thermistor_Temp(15) = 1000
Thermistor_R(15) = 1
For Counter = 0 To 15
If CInt(TextBoxResistance.Text) >= Thermistor_R(Counter) Then
If Counter <> 0 And Counter <> 15 Then
Temperature_high = Thermistor_Temp(Counter)
Temperature_low = Thermistor_Temp(Counter - 1)
Resistance_low = Thermistor_R(Counter)
Resistance_high = Thermistor_R(Counter - 1)
Rnum1 = Resistance_high - TextBoxResistance.Text
Rnum2 = Resistance_high - Resistance_low
Result = 2.5 + Math.Round(Temperature_low + (5 * Rnum1 / Rnum2), 1)
TextBoxTemp.Text = Result & "C"
Exit For
If Counter = 0 Or Counter = 15 Then
TextBoxTemp.Text = "Out Of Range"
Exit For
End If
End If
End If
Next
End Sub
Private Sub TimerTemp_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerTemp.Tick
Call OpenPort1()
TextBoxVoltage.Clear()
TextBoxResistance.Clear()
TextBoxTemp.Clear()
SerialPortTemp.WriteLine("U1" + vbCr)
System.Threading.Thread.Sleep(150)
Call ReadSerialPortForTemp()
If Len(TextBoxVoltage.Text) = 0 Then
Else
Circuit_Thermistor_R = 10000 * TextBoxVoltage.Text / (5 - TextBoxVoltage.Text)
TextBoxResistance.Text = Math.Round(Circuit_Thermistor_R, 0)
Call ThermistorTable()
End If
End Sub
Private Sub TimerSpeak2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerSpeak2.Tick
Call ThermistorTable()
If CheckBox1.Checked = True Then //from this part
Call ThermistorTable()
If Result >= 0 Then
TextBox.Text = ""
TextBox.Text = "Your Temperature is" + "" + TextBoxTemp.Text
TextBox.Refresh()
Speaker.Speak(TextBox.Text)
End If //to this part
|
|
|
|
|
Though I do not usually do this, I have spent five minutes to parse your code snippet correctly. What I can see is that Thermistor_Temp and Thermistor_R arrays have always the same values, so you should better initialize them just once in the constructor, becouse you are now initializing them with the same values every time you call ThermistorTable.
In this loop in ThermistorTable method:
For Counter = 0 To 15
If CInt(TextBoxResistance.Text) >= Thermistor_R(Counter) Then
If Counter <> 0 And Counter <> 15 Then
Temperature_high = Thermistor_Temp(Counter)
Temperature_low = Thermistor_Temp(Counter - 1)
Resistance_low = Thermistor_R(Counter)
Resistance_high = Thermistor_R(Counter - 1)
Rnum1 = Resistance_high - TextBoxResistance.Text
Rnum2 = Resistance_high - Resistance_low
Result = 2.5 + Math.Round(Temperature_low + (5 * Rnum1 / Rnum2), 1)
TextBoxTemp.Text = Result & "C"
Exit For
If Counter = 0 Or Counter = 15 Then
TextBoxTemp.Text = "Out Of Range"
Exit For
End If
End If
End If
Next
I guess you are looking for the first value on your array which is lesser or equal to what you have in TextBoxResistance. Not too bad, but somewhat confusing, and the last if will never run. I would have done it this way:
Dim r As Integer = CInt(TextBoxResistance.Text)
Dim idx As Integer = 0
While r < Thermistor_R(idx) And idx < 15
idx += 1
End While
If (idx = 0 Or idx = 15) Then
TextBoxTemp.Text = "Out Of Range"
Else
Temperature_high = Thermistor_Temp(idx)
Temperature_low = Thermistor_Temp(idx - 1)
Resistance_low = Thermistor_R(idx)
Resistance_high = Thermistor_R(idx - 1)
Rnum1 = Resistance_high - r
Rnum2 = Resistance_high - Resistance_low
Result = 2.5 + Math.Round(Temperature_low + (5 * Rnum1 / Rnum2), 1)
TextBoxTemp.Text = Result & "C"
End If
Anyhow, you get an error trying to convert a string to an Integer. It must be becouse you try to convert a TextBox.Text property before you have initialized its value, so it has nothing to do with your CheckBox. Like you are using different timers to read and modify the values, I think you have not synchronized them correctly.
On the other hand, this is too much UI dependent. I would rather encapsulate all this stuff within a class and use just one timer to update the UI controls with the values this class returns.
|
|
|
|
|
Thanks It work already Cheer to programmer
|
|
|
|
|
hi,
i have written a code,my current code captures real time temperature,it adds the captured temperature to the database.But the problem is the code keeps running infinite.I want it to start from 0(database slot) and stop at 288 (database slot)and to keep running in a loop.How do i do it.Please advice.
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Dim cBuilder As New OleDb.OleDbCommandBuilder(dAdapter)
Dim dsNewRow As DataRow
dsNewRow = dSet.Tables("test1").NewRow()
dsNewRow.Item("Temperature") = TextBox8.Text
dSet.Tables("test1").Rows.Add(dsNewRow)
dAdapter.Update(dSet, "test1")
dSet.Clear()
dAdapter.Fill(dSet, "test1")
End Sub
|
|
|
|
|
so count the number of times your code snippet is running and make the timer stop when you had enough.
|
|
|
|
|
i understand by putting a timer, it will stop it from sending temperature data to the database.. but i also need it to send data up to 288 and overwrite the data from 0-288 again
|
|
|
|