|
KaKa` wrote: How do we make a listbox to respond directly when the user clicks on the items
You catch the SelectedIndexChange event. So yes, you are on the right track.
The SelectedIndexChange event is only raised when the user selects a different item in the list. It's raised when you click or arrow through the items in the list. It should be just that simple.
KaKa` wrote: The SelectedIndexChange event only seems to work when a button is added.
When a button is added? Huh? What exactly are you doing here?
Also, the SelectedIndexChange event should not be effected by buttons. There must be something wrong in your code. Perhaps you should post your SelectedIndexChange code.
|
|
|
|
|
Not sure why yours did not work from SelectedIndexChanged but here is a code cut to use and try.
<br />
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles listStat.SelectedIndexChanged<br />
If listStat.SelectedIndices.Count > 0 Then<br />
<br />
Label1.Text = ListBox1.SelectedItems(0).Text<br />
<br />
End If<br />
If you list box is static you can get the index (integer) and in a Select / Case statement fire off different events. If the list box is populated dynamically you will have to loop through and pull out the index.
Jason
When people make you see red, be thankful your not colour blind.
|
|
|
|
|
Hello,
I want to create a Custom Minimize & Maximize/Restore button in VB.Net. Can anybody tell me that What is the code for Minimize, Maximize/Restore Window.
Thanks In Adv.
-- modified at 21:07 Monday 20th February, 2006
|
|
|
|
|
Me.WindowState = FormWindowState.Minimized
Me.WindowState = FormWindowState.Maximized
chatura
|
|
|
|
|
hi again,
can it possible to make Panel control scrollable? How?
Thanks in Adv.
|
|
|
|
|
Yes.
In the designer select the panel on your form, go to its property panel, and set AutoScroll to True.
Afterwards, scrollbars will automatically appear when controls no longer fit inside the panel.
|
|
|
|
|
Is there a way to hide the console window in a console application? Or if not is it possible to open a command window in a Windows application? Any help is greatly appreciated.
|
|
|
|
|
|
coder45 wrote: Is there a way to hide the console window in a console application?
So do you not want to display the console window at all? Ever?
In that case, create a WinForm project without any forms.
coder45 wrote: Or if not, is it possible to open a command window in a Windows application?
You can launch a console window like this. The second argument passes a string of command line arguments.
System.Diagnostics.Process.Start("cmd", "/?")
|
|
|
|
|
Wonder if any of you guys can point me in the right direction? I'm really new to VB.NET, and its probably really simple, but I'm wondering if there is a VB.NET equivalent of the MSAccess &variable trick that I've often used to have Access use a string as the variable??
For example, the current snippet of VB.NET code reads:
Do While intCheckBoxesToCount < 12
strCheckVariable = "CheckBox" & System.Convert.ToString(intCheckBoxesToCount)& ".Checked"
... and then I want to perform some analysis of my string. What I was hoping for was something along the lines of ...
If &strCheckVariable = True Then .....
|
|
|
|
|
Why not keep an array of CheckBox control references and loop through that?
Class Foo : Inherits System.Windows.Forms.Form
<code>Public myCheckBoxes() As CheckBox</code>
'
Private Sub Foo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
<code> myCheckBoxes = New CheckBox() {CheckBox1, CheckBox2, CheckBox3}</code>
'
' Do something...
'
<code>For Each chkBox As CheckBox In myCheckBoxes
If (chkBox.Checked) Then
' CheckBox is checked!
End If
Next</code>
End Sub
End Class
|
|
|
|
|
Thanks - this works well
|
|
|
|
|
Dear Friends, I need to save some sounds like "a" and "b" sound. Then I want my software to play them together without any break between those two sounds. Do you have any clue about this? For example I can play 2 recorded sounds by this code below. But there is some break between them. Can I prevent that break? Thanks for help.
Private Sub Command2_Click()
Dim Array1(1 To 10) As String
Dim Yol As String
Dim Tur As String
Yol = "C:\Proje\Sounds\"
Tur = ".wav"
Array1(1) = "a"
Array1(2) = "b"
Array1(3) = "c"
For i = 1 To 3
Call Play(Yol, Array1(i), Tur)
Next i
End Sub
Sub Play(Yol As String, Ses As String, Tur As String)
OLE2.SourceDoc = Yol + Ses + Tur
OLE2.Action = 1
OLE2.Action = 7
End Sub
-- modified at 16:27 Monday 20th February, 2006
|
|
|
|
|
hello
i have a combobox with the following data:
KL1
KL10
KL2
KL3
But I want to sort the combobox alphabetically and numeric
so I want to have;
KL1
KL2
KL3
KL10
Any idea how I can do that?
Thebest
|
|
|
|
|
Hi,
Maybe you can try to list as KL01, KL02, KL03 and so on... In this way, it will sort out as KL01, KL02, KL03, KL10.
Chiari
-- modified at 20:08 Monday 20th February, 2006
|
|
|
|
|
I have a project that stores names to a database successfully until of course I hit a name like O'Conner. Then it hits me with a Syntax error (missing operator) in query expression ''Gary O'Connor', 'Dundee United', '18',71, 'Normal')'.
And it only happens with this guys name. So I gather that its the "'" in his O'Conner that messes it up.
How can I fix it? Here is my insert statement.
sCommAdd += "INSERT INTO Goals (Name, ScoredAgainst, Minutes, FixtureID, GoalType) VALUES ('" + P + "', '" + SCA + "', '" + Min + "'," & FID & ", '" + GT + "')"
|
|
|
|
|
You're having this problem because your using string concantentation to build SQL statements. Use parameterized queries instead and you won't have to worry about it at all.
The technique is decsribed in SQL Injection Attacks and Some Tips on How to Prevent Them
[^] by Colin Angus Mackay.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
or you can simply replace "'" with """"
WiL
|
|
|
|
|
Use this function
function NewString(string)
NewString = Replace(string, "'" , "''" )
end function
this should solve your problem...
With Best Regards,
Mayur
-- modified at 23:05 Monday 20th February, 2006
|
|
|
|
|
And I say learn to do it correctly, before you learn a bad habit.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How cain i convert Stream data Image to Image?
I get from Http a Stream data Image but when i will convert to image, always have trouble to Parameters. Anybody know how can i do this? Thanks..
Vander
|
|
|
|
|
Just load the image from the stream:
MyImage = Image.FromStream(theStream)
---
b { font-weight: normal; }
|
|
|
|
|
I hope this helps, its 2.0 code.
Read the input stream into a byte array.
<br />
Dim len As Integer = File1.PostedFile.ContentLength<br />
Dim fileContents() As Byte = New Byte(len) {}<br />
File1.PostedFile.InputStream.Read(fileContents, 0, len)<br />
<br />
<br />
SaveFile(IntFormID, FileName, fileContents)<br />
<br />
<br />
<br />
Public Shared Sub SaveFile(ByVal FormID As Integer, ByVal FileName As String, ByVal File As Byte())<br />
<br />
Dim conn As New SqlConnection(CStr(Current.Session("ConnectionString")))<br />
Dim cmd As New SqlCommand()<br />
cmd.Connection = conn<br />
cmd.CommandType = CommandType.StoredProcedure<br />
cmd.CommandText = "dbo.uspSaveFile"<br />
AddFormIDParameter(cmd, FormID)<br />
<br />
Dim PrmFileImage As New SqlParameter("@File", SqlDbType.Image)<br />
PrmFileImage.Direction = ParameterDirection.Input<br />
cmd.Parameters.Add(PrmFileImage)<br />
PrmFileImage.Value = File<br />
<br />
Dim PrmFileName As New SqlParameter("@FileName", SqlDbType.VarChar, 100)<br />
PrmFileName.Direction = ParameterDirection.Input<br />
cmd.Parameters.Add(PrmFileName)<br />
PrmFileName.Value = FileName<br />
<br />
AddNetIDParameter(cmd)<br />
<br />
conn.Open()<br />
cmd.ExecuteNonQuery()<br />
conn.Close()<br />
<br />
<br />
<br />
<br />
<br />
<br />
End Sub<br />
"People who never make mistakes, never do anything."
My Blog
|
|
|
|
|
hi guy, can u help me convert this code to VB6 or VB .Net??
/* Version 0.1 of F5 Steganography Software by Andreas Westfeld 1999 */
/*********************************************************/
/* JPEG Decoder */
/* Sean Breslin */
/* EE590 Directed Research */
/* Dr. Ortega */
/* Fall 1997 */
/* */
/* HuffTable.class: */
/* Extracts Huffman table from image header */
/* data. Instanciate one class for each table */
/* in the file the header. */
/* */
/* Methods: */
/* getHUFFVAL(), returns HUFFVAL array */
/* getVALPRT(), returns VALPTR array */
/* getMAXCODE(), returns MAXCODE array */
/* getMINCODE(), returns MINCODE array */
/* */
/********************** 11/4/97 **************************/
/* /////////////// DISCLAIMER/////////////////////////////////
This software is provided by the author and
contributors ``as is'' and any express or implied
warranties, including, but not limited to, the
implied warranties of merchantability and
fitness for a particular purpose are dis-
claimed. In no event shall the author or con-
tributors be liable for any direct, indirect,
incidental, special, exemplary, or consequen-
tial damages (including, but not limited to,
procurement of substitute goods or services;
loss of use, data, or profits; or business
interruption) however caused and on any
theory of liability, whether in contract,
strict liability, or tort (including negligence
or otherwise) arising in any way out of the use
of this software, even if advised of the poss-
ibility of such damage.
//////////////////////////////////////////////////////*/
// westfeld
package ortega;
import java.io.*;
public class HuffTable {
// Instance variables
private int[] BITS = new int[17];
private int[] HUFFVAL = new int[256];
private int[] HUFFCODE = new int[257];
private int[] HUFFSIZE = new int[257];
private int[] EHUFCO = new int[257];
private int[] EHUFSI = new int[257];
private int[] MINCODE = new int[17];
private int[] MAXCODE = new int[18];
private int[] VALPTR = new int[17];
private int Ln, SI, I, J, K, LASTK, CODE;
// Constructor Method
public HuffTable(DataInputStream d, int l) {
dis = d;
// System.out.println("L鋘ge="+l);
// Get table data from input stream
Ln=19+getTableData();
// System.out.println(Ln);
Generate_size_table(); // Flow Chart C.1
Generate_code_table(); // Flow Chart C.2
Order_codes(); // Flow Chart C.3
Decoder_tables(); // Generate decoder tables Flow Chart F.15
}
public int getLen() {
return Ln;
}
// IO MethodS
public int[] getHUFFVAL() { return HUFFVAL; }
public int[] getVALPTR() { return VALPTR; }
public int[] getMAXCODE() { return MAXCODE; }
public int[] getMINCODE() { return MINCODE; }
private int getByte() {
try {
return dis.readUnsignedByte();
}
catch (IOException e) { return -1; }
}
private int getTableData(){
// Get BITS list
int count=0;
for(int x=1;x<17;x++) {
BITS[x] = getByte();
count += BITS[x];
}
// Read in HUFFVAL
for(int x=0;x<count;x++){
system.out.println(ln);
="" huffval[x]="getByte();
" }
="" return="" count;
="" }
="" private="" void="" generate_size_table()="" {
="" generate="" huffsize="" table="" flow="" chart="" c.1
="" k="0;" i="1;" j="1;
" while(true)="" if(j="">BITS[I]) {
J=1; I++;
if(I > 16)
break;
}
else {
HUFFSIZE[K++]=I;
J++;
}
}
HUFFSIZE[K] = 0;
LASTK = K;
}
private void Generate_code_table() {
// Generate Code table Flow Chart C.2
K = 0; CODE = 0; SI = HUFFSIZE[0];
while(true) {
HUFFCODE[K++] = CODE++;
if(HUFFSIZE[K] == SI)
continue;
if(HUFFSIZE[K] == 0)
break;
while(true){
CODE<<=1;
SI++;
if(HUFFSIZE[K] == SI)
break;
}
}
}
private void Order_codes() {
// Order Codes Flow Chart C.3
K=0;
while(true) {
I = HUFFVAL[K];
EHUFCO[I] = HUFFCODE[K];
EHUFSI[I] = HUFFSIZE[K++];
if(K >= LASTK) break;
}
}
private void Decoder_tables() {
// Decoder table generation Flow Chart F.15
I = 0; J = 0;
while(true) {
if(++I > 16)
return;
if(BITS[I] == 0)
MAXCODE[I] = -1;
else {
VALPTR[I] = J;
MINCODE[I] = HUFFCODE[J];
J = J + BITS[I] - 1;
MAXCODE[I] = HUFFCODE[J++];
}
}
}
// Declare input steam
DataInputStream dis;
}
|
|
|
|
|
Try somthing like this, you'll have to work out the bugs:
'/----------------------------------------------------
Imports System
Namespace ortega
Public Class HuffTable
Public Overridable ReadOnly Property Len() As Integer
Get
Return Ln
End Get
End Property
Private ReadOnly Property Byte() As Integer
Get
Try
Return dis.ReadByte
Catch e As System.IO.IOException
Return -1
End Try
End Get
End Property
Private ReadOnly Property TableData() As Integer
Get
Dim count As Integer = 0
Dim x As Integer = 1
While x < 17
BITS(x) = Byte
count += BITS(x)
System.Math.Min(System.Threading.Interlocked.Increment(x),x-1)
End While
Dim x As Integer = 0
While x < count
HUFFVAL(x) = Byte
System.Math.Min(System.Threading.Interlocked.Increment(x),x-1)
End While
Return count
End Get
End Property
Private BITS As Integer() = New Integer(17) {}
Private HUFFVAL As Integer() = New Integer(256) {}
Private HUFFCODE As Integer() = New Integer(257) {}
Private HUFFSIZE As Integer() = New Integer(257) {}
Private EHUFCO As Integer() = New Integer(257) {}
Private EHUFSI As Integer() = New Integer(257) {}
Private MINCODE As Integer() = New Integer(17) {}
Private MAXCODE As Integer() = New Integer(18) {}
Private VALPTR As Integer() = New Integer(17) {}
Private Ln As Integer
Private SI As Integer
Private I As Integer
Private J As Integer
Private K As Integer
Private LASTK As Integer
Private CODE As Integer
Public Sub New(ByVal d As System.IO.BinaryReader, ByVal l As Integer)
dis = d
Ln = 19 + TableData
Generate_size_table
Generate_code_table
Order_codes
Decoder_tables
End Sub
Public Overridable Function getHUFFVAL() As Integer()
Return HUFFVAL
End Function
Public Overridable Function getVALPTR() As Integer()
Return VALPTR
End Function
Public Overridable Function getMAXCODE() As Integer()
Return MAXCODE
End Function
Public Overridable Function getMINCODE() As Integer()
Return MINCODE
End Function
Private Sub Generate_size_table()
K = 0
I = 1
J = 1
While True
If J > BITS(I) Then
J = 1
System.Math.Min(System.Threading.Interlocked.Increment(I),I-1)
If I > 16 Then
' break
End If
Else
HUFFSIZE(System.Math.Min(System.Threading.Interlocked.Increment(K),K-1)) = I
System.Math.Min(System.Threading.Interlocked.Increment(J),J-1)
End If
End While
HUFFSIZE(K) = 0
LASTK = K
End Sub
Private Sub Generate_code_table()
K = 0
CODE = 0
SI = HUFFSIZE(0)
While True
HUFFCODE(System.Math.Min(System.Threading.Interlocked.Increment(K),K-1)) = System.Math.Min(System.Threading.Interlocked.Increment(CODE),CODE-1)
If HUFFSIZE(K) = SI Then
' continue
End If
If HUFFSIZE(K) = 0 Then
' break
End If
While True
CODE <<= 1
System.Math.Min(System.Threading.Interlocked.Increment(SI),SI-1)
If HUFFSIZE(K) = SI Then
' break
End If
End While
End While
End Sub
Private Sub Order_codes()
K = 0
While True
I = HUFFVAL(K)
EHUFCO(I) = HUFFCODE(K)
EHUFSI(I) = HUFFSIZE(System.Math.Min(System.Threading.Interlocked.Increment(K),K-1))
If K >= LASTK Then
' break
End If
End While
End Sub
Private Sub Decoder_tables()
I = 0
J = 0
While True
If System.Threading.Interlocked.Increment(I) > 16 Then
Return
End If
If BITS(I) = 0 Then
MAXCODE(I) = -1
Else
VALPTR(I) = J
MINCODE(I) = HUFFCODE(J)
J = J + BITS(I) - 1
MAXCODE(I) = HUFFCODE(System.Math.Min(System.Threading.Interlocked.Increment(J),J-1))
End If
End While
End Sub
Friend dis As System.IO.BinaryReader
End Class
End Namespace
'/------------------------------------------------
progload
|
|
|
|
|