|
I don't think you can do it without the two, if you are using database.
Please wait for another reply.
|
|
|
|
|
How else are you going to get the data out of the database?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am a new learner of VB.net.
Can anybody let me know, how to call a buton_click procedure on textbox.keypress event.
Suman Singh
suman9730@hotmail.com
|
|
|
|
|
place the following line of code into your keypress event handler:
me.myButton.PerformClick()
-jim
|
|
|
|
|
Hi,
Thanks for your quick reply.
But how can I identify the button if i have 5 buttons on the form.
Please help again.
A learner this side.
Thanks!
|
|
|
|
|
is it a situation where you want to perform a click on a particular button based on which text box has the focus?
if this is the case, just evaluate what you want to determine and perform a click on the appropriate button. for instance
Private Sub myKeyPressHandler(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles myTextBox.KeyPress,
someOtherTextBox.KeyPress,
yetAnotherTextBox.KeyPress
If (Object.ReferenceEquals(sender, Me.myTextBox)) Then
me.myButton.PerformClick()
elsif (object.ReferenceEquals(sender, me.someOtherTextBox))
me.someOtherButton.PerformClick()
elseif (object.ReferenceEquals(sender, me.yetAnotherButton))
me.yetAnotherButton.PerformClick()
else
messagebox.show("It was yet even another textbox that received the text!")
End If
End Sub hope this helps you out.
-jim
|
|
|
|
|
Thanks again Jim,
I want to press Enter key in textbox after giving my password (let say)
And by pressing Enter key, the code written in
Private sub Login_Validate_button(by val sender as object......)handles....
----
----
----
End Sub
get invoked.
How can I call this button procedure by pressing the Enter key in textbox.
Thanks !
|
|
|
|
|
no problem Suman,
in this case, just handle the keypress as follows...
private sub txtPassword_KeyPress(byval sender as object, byval e as System.windows.forms.keyeventargs) handles txtPassword.KeyPress
if (e.keycode=keys.enter) then
me.btnLogin.PerformClick()
end if
End Sub when working with event handlers, always look to the event arguments for context specific data regarding the event being raised.
-jim
|
|
|
|
|
i need to loop some rows in my datagrid to add them and show the total.
i am using:
<br />
Dim dr As DataRow<br />
Dim Amount As Double = 0<br />
For Each dr As System.Data.DataRow _<br />
In ds.Tables(0)<br />
dr = dr + ds.Tables(0).Rows.Item("Amount")<br />
Next<br />
Me.Text = ("My Balance $") & Amount.ToString<br />
everything is fine except the underlined part. it keeps saying that it is a member of system.data.datatable which is not a collection type. does anyone know what i am doing wrong?
Makniteasy
|
|
|
|
|
Tables(0) is not a collection, it's a specific table.
...
For each r as Datarow in ds.Tables(0).Rows
... by the way your initial declaration of dr is reduntant since you are initializing it again within your for statement. just thought i'd mention it.
-jim
|
|
|
|
|
thanks that fixed that problem but now i have another:
<br />
Dim Amount As Double = 0<br />
<br />
For Each dr As DataRow In ds.Tables(0).Rows<br />
<br />
dr = dr + ds.Tables(0).item("Amount")<br />
<br />
Next<br />
Me.Text = ("My Balance $") & ("Amount").ToString<br />
now this is underlined. i think im lost in the loop now.any more suggestions?
Makniteasy
|
|
|
|
|
can you give us an idea of exactly what it is you're trying to do? the code you've provided doesn't really make much sense.
just a brief description should help.
-jim
|
|
|
|
|
You're not adding the amounts. You're actually trying to add a Column to a DataRow.
I think you're looking for:
Dim Amount As Double = 0
For Each dr As DataRow In ds.Tables(0).Rows
Amount += dr.Item("Amount")
Next
Me.Text = "My Balance $" & Amount.ToString()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks for the help. The help you provided was exactly what i needed. i was trying to get the amount column of a datagrid, for which the user enters the amount they paid, to show in the datagrid caption text when entered.
I am going to post another question so that you wont have to keep to returning this one.
thanks
Makniteasy
|
|
|
|
|
I'm having another issue with my little HTA application that I'm hoping you could advise on.
Basically when a user enters a PC name in a box and selects GO. I want the code to run a ping against the remote machine to see if it is online or not. Now in a normal vb script the IsConnectible ping check works great. However when called from within my HTA app it always come back and says that the PC is online.
Anyone know why its not working in the HTA?
This is my code...thanks
<title>System Information
<hta:application
="" id="objSysInfo" applicationname="System Information" scroll="yes" singleinstance="yes" windowstate="maximize">
Sub MainSub
On Error Resume Next
DataArea.InnerHTML= " "
sComputer = ComputerTextBox.Value
If sComputer = Empty Then
strHTML = strHTML & "Please Enter a Computer Name "
DataArea.InnerHTML = strHTML
Else
If IsConnectible(sComputer,"","") Then
strHTML = strHTML & "Computer is online"
Else
strHTML = strHTML & "Computer is offline"
End If
DataArea.InnerHTML = strHTML
End If
End Sub
Sub IsConnectible(sHost, iPings, iTO)
' Returns True or False based on the output from ping.exe
'
' Author: Alex Angelopoulos/Torgeir Bakken
' Works an "all" WSH versions
' sHost is a hostname or IP
' iPings is number of ping attempts
' iTO is timeout in milliseconds
' if values are set to "", then defaults below used
If iPings = "" Then iPings = 2
If iTO = "" Then iTO = 750
Const OpenAsDefault = -2
Const FailIfNotExist = 0
Const ForReading = 1
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sTemp = oShell.ExpandEnvironmentStrings("%TEMP%")
sTempFile = sTemp & "\runresult.tmp"
oShell.Run "%comspec% /c ping -n " & iPings & " -w " & iTO _
& " " & sHost & ">" & sTempFile, 0 , True
Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, _
FailIfNotExist, OpenAsDefault)
sResults = fFile.ReadAll
fFile.Close
oFSO.DeleteFile(sTempFile)
IsConnectible = CBool(InStr(sResults, "TTL="))
End Sub
|
|
|
|
|
You might want to check the contents of your Temp file that PING write first, before you delete it. I think the answer to your question will be in there.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Can someone PLEASE look at the following code??
<code>
<Serializable()> _
Public Class SerialDataPack
Public Shared PLCname As String '-- PLC Station name
Public Shared Reason As Reasons '-- Enumerate of reason to send
Public Shared File() As Byte '-- File as bytearray
Enum Reasons
[STARTUP]
[EVENT]
[REQ]
[GENREQ]
End Enum
End Class</code>
i serialize the object, send it to the other client and do the following code:
<code>Dim filepath As String = "c:\PLC\Listener\Received\Temp " & EventCounter & ".bin"
'-- write this file to HDD location filepath;
Dim BW As New BinaryWriter(File.OpenWrite(filepath))
BW.Write(Buffer, 0, numbytes)
BW.Close()
'-- then read it back with binaryformatter
Dim bf As BinaryFormatter = New BinaryFormatter
Dim fs = New FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim SocketListenerSDRecv As SerialData.SerialDataPack
'-- similair to CType but faster runtime according to MSDN
SocketListenerSDRecv = DirectCast(bf.Deserialize(fs), SerialData.SerialDataPack)
fs.Close()</code>
when i DESERIALIZE the fs i get the folowing error (and CType spawns same error);
"The given conversion is invalid"
does someone has a suggestion, maybe i should re-implement my serializable class?????
If you make something idiotproof, someone else will make a better idiot.....
|
|
|
|
|
You haven't shown us the code that is doing the serializing of the object...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dear mr Kreskowak,
I replied, but added the new code under my own posting thread
Yours sincerely,
If you make something idiotproof, someone else will make a better idiot.....
|
|
|
|
|
addendum, i really wanna serialize the whole class in 1 command( and deserilze too)
So, As asked for: The serialazation process
Dim io As MemoryStream = New MemoryStream<br />
Dim SdServerSend As SerialClass.SerialDataPack = new SerialClass.SerialDataPack<br />
<br />
'-- set .plcname in serialized packet<br />
SdServerSend.PLCname = Form1.stTelemeOut.PLCname<br />
<br />
Dim Bf As BinaryFormatter = New BinaryFormatter<br />
<br />
'-- convert the file to send to a byte array<br />
Dim Br As New BinaryReader(File.OpenRead(filepath))<br />
Dim bytes() As Byte = Br.ReadBytes(Br.BaseStream.Length)<br />
Br.Close()<br />
<br />
'-- copy array to .file<br />
SdServerSend.File = bytes<br />
<br />
'-- serialize class to IO stream<br />
Bf.Serialize(io, SdServerSend)<br />
<br />
'-- writes IO to hdd<br />
Dim BW As New BinaryWriter(File.OpenWrite("C:\PLC\Listener\Received\temptest " & SdServerSend.Reason.ToString & " " & EventCounter & ".bin"))<br />
BW.Write(io.GetBuffer, 0, io.Length)<br />
BW.Close()<br />
<br />
'-- reset io.postion to 0<br />
io.Position = 0<br />
<br />
'-- send serialized data to listener<br />
Form1.ClientSocket.Send(io.GetBuffer, io.Length, 0)
If you make something idiotproof, someone else will make a better idiot.....
|
|
|
|
|
hi evry1,
i have to populate menus thru an Access database in VB 6.0
i know how to generate main menu and menu items at runtime in VB.NET, but what i want to know is that, how do i perform the same thing in VB 6.0?
there is no mainMenu property in a VB 6.0 form. Secondly i can add a menu item using a cotrol array of a menu, but this doesnt allow me to create a sub menu of a newly added menu.
Please help me!!!
thanx in advance
☺«««DTA»»»☺
|
|
|
|
|
To add submenus dynamically in VB6 you need to create a place holder top level menu and set it's Index property to 0. Then add sub menus by index.
|
|
|
|
|
Dear all,
Anyone can hide the tabpages in tabcotrol
Don't tell follows
Me.TabControl1.TabPages.Item(0).Visible = False
This is not working
And also can you draw line on tabpages
rugfy
Ishak
|
|
|
|
|
rugfy wrote:
Anyone can hide the tabpages in tabcotrol
You cannot hide the page, but you can use the TabPages collection of the Tab Control to remove the page altogether.
If you need to be able to add the TabPage back dending on some condition, you can save the TabPage in a Collection before you remove it. Because adding the page back in order is a hassle, the easiest thing to do is when you initialize the form, add all TabPages to the collection in the correct order. Then if you remove a TabPage and need to add it back later, just remove all TabPages and then replace them all in order from the collection.
Of course, you will lose any data that has been entered if you use this approach, so you may have to add additional code if you need to maintain the data state...
You can draw a line on a TabPage using the Graphics object. However, if you are going to be removing tabpages at run time, the events could get complicated. The easiest way to create a line is to create a Panel on the tab page, set it's BackColor to the color of the line you want, and set it's height to 1 pixel.
|
|
|
|
|
Thanx a Lot
But I don't need it ,My actual Think is i want to give the distance between two pages like seperator in toolbar for some elegant look.thats all.In this case my doubt is whats the use of
Tabcontrol.Tabpages(0).Vaiable = False
Does it doing nothing Thats Why
Any way Once Thanx For your reply
Ishak
|
|
|
|