|
what r the accounts dealing in hotel management
|
|
|
|
|
Ask your team's Certified Public Accountant.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
i am facing problem with date format,i have sql server database table in that, one column is date.the that date format is mm/dd/yy.so when i write the xml using vb.net Tool that time it displayed as date yy/mm/dd.but i want mm/dd/yy format could u plz any one help me on this topic.
Charan04
-- modified at 5:40 Monday 10th July, 2006
|
|
|
|
|
datetime.now.tostring("MM/dd/yyyy")
|
|
|
|
|
Thanks for that one ,But i want mm/dd/yyy this format when write xml that time they will print like yy/dd/mm.in my datebase format is(table)mm/dd/yy.plz give answer.
charan04
|
|
|
|
|
I'm attempting to export emails the user has selected in outlook. I wrote this as a vb macro inside of Outlook, but get a message stating do you want to allow the process and then there is a drop down for 1 or 10 minutes to allow. Does anyone know how I can get around this and always allow.
|
|
|
|
|
I have been searching alot and still having lots of error to write coding for DataGrid_DragDrop. I need help urgently
Public Sub TreeView_ItemDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles TreeView.ItemDrag<br />
m_tnSource = CType(e.Item, TreeNode)<br />
DoDragDrop(e.Item, DragDropEffects.Move)<br />
End Sub<br />
<br />
Private Sub DataGrid_DragEnter(ByVal Sender As Object, ByVal e As DragEventArgs) Handles DataGrid.DragEnter<br />
If e.Data.GetDataPresent(DataFormats.Text) Then<br />
e.Effect = DragDropEffects.Copy<br />
Else<br />
e.Effect = DragDropEffects.None<br />
End If<br />
End Sub
-- modified at 4:02 Monday 10th July, 2006
|
|
|
|
|
Hi,
I've got some code thats unamanged/managed and have some callback handlers in it, linking some old .dll stuff.
I've searched for a while and I've read a bit on garbage collection and delegates and I've tried my best to apply the examples to my code, but to no avail. I still get either the following error message
"A callback was made on a garbage collected delegate of type 'WindowsApplication1!WindowsApplication1.MyConnectHandler::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called."
or, no error message (and the call back excutes successfully) but it then trashes the other bits of code from working properly that are run from the same .dll
This is the code, I've cut out the surplus bits, it has no errors or warnings...... just doesn't work
In this sample basically the user would select a comport from a drop down box and click connect. I know it actually connects as I can see status from the device its connecting to. However when the device tries to send the message back, it does one of the above errors.
Would greatly appreciate any help as I'm trying to implement this .dll to move away from an unstable module we are being forced to use at the moment.
Michael
imports System.Text
Public Delegate Sub MyConnectHandler(ByVal result As Integer)
Public Class Form1
Inherits System.Windows.Forms.Form
' Declare some variables
Public Declare Auto Sub register_connect_handler Lib "CBM.DLL" Alias "_register_connect_handler" (ByVal FPtr As MyConnectHandler)
Dim MyConnectPtr As MyConnectHandler = AddressOf Connect_Handler
Public Sub Connect_Handler(ByVal result As Integer)
If result = 0 Then
Me.StatusBar1.Text = "Fail"
Call close_com_port()
ElseIf result = 1 Then
Me.StatusBar1.Text = "Fail type 2"
Call close_com_port()
ElseIf result = 2 Then
' success so enable trackbar and inform user
connected = 1
Me.TrackBar1.Enabled = True
Me.StatusBar1.Text = "Connected"
End If
End Sub
' Initialise fields and vars
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i, j As Int16
' Launch the connect handler
register_connect_handler(MyConnectPtr)
' Stop it from dying
GC.KeepAlive(MyConnectPtr)
End Sub
' Connect/disconnect as required
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim [ascii] As Encoding = Encoding.ASCII
Dim Port As Byte() = [ascii].GetBytes(Me.ComboBox1.Text)
Dim x As Integer
If connected = 0 Then
' connecting, inform user
Me.StatusBar1.Text = "Connecting ..."
' Open the selected comport (DLL call)
x = open_com_port(Port)
' check result of call for success
If x = 0 Then
' failure, inform user
Me.StatusBar1.Text = "Connect failed"
End If
Else
' disconnecting
connected = 0
' close the com port (DLL call)
Call close_com_port()
' inform the user
Me.StatusBar1.Text = "Disconnected"
Me.TrackBar1.Enabled = False
End If
End Sub
End Class
|
|
|
|
|
hi to all and best of luck. )I'm stuck-up here with the problem .. I could manage to pass string to another process/application using WM_COPYDATA but it takes v. long to pass a structure.
i wish if you can give me any code that allows passing "structure" between 2 applications
------------this is class one - sending message
Imports System.Runtime.InteropServices
Public Class clsIPC
Inherits System.Windows.Forms.NativeWindow Implements IDisposable
Private Const GLOBAL_IDENTITY_ONE = "GLOBAL_IDENTITY_ONE"
Private Const GLOBAL_IDENTITY_TWO = "GLOBAL_IDENTITY_TWO"
Private Const MESSAGE_FOR_ONE = "MESSAGE_ONE"
Private Const MESSAGE_FOR_TWO = "MESSAGE_TWO"
Private Const WM_COPYDATA As Integer = &H4A
#Region "API Declaration"
<structlayout(layoutkind.sequential)> _
Private Structure CopyData
Public dwData As IntPtr
Public cbData As Integer
Public lpData As IntPtr
End Structure
Private Declare Auto Function SendMessage Lib "user32" _
(ByVal hWnd As IntPtr, _
ByVal Msg As Integer, _
ByVal wParam As IntPtr, _
ByRef lParam As CopyData) As Boolean
Private Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" _
(ByVal lpString As String) As IntPtr
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As IntPtr, ByVal wMsg As IntPtr, ByVal wParam As Integer, _
ByVal lParam As Integer) As IntPtr
#End Region
#Region "process for messanging to application GLOBAL_IDENTITY_TWO"
'get handle of globlal application named GLOBAL_IDENTITY_TWO
Public ReadOnly Property GET_HANDLE_TWO() As IntPtr
Get
Return FindWindow(vbNullString, GLOBAL_IDENTITY_TWO)
End Get
End Property
Structure PT
Dim x As Object
Dim y As Char
Dim xy As String
End Structure
Dim MyVariable As New PT
Public Function sendMessageToTwo()
Dim data As CopyData
Dim message As String = "this is to be sent"
Dim hwndTarget As IntPtr
Dim MessageId As IntPtr
hwndTarget = Me.GET_HANDLE_TWO
MessageId = ONE_TO_TWO_MESSAGEID()
MyVariable.x = message
MyVariable.y = "c"
MyVariable.xy = "String is here"
System.GC.KeepAlive(MyVariable)
data.lpData = Marshal.AllocHGlobal(Marshal.SizeOf(MyVariable))
data.cbData = Marshal.SizeOf(MyVariable)
Dim MyPointer As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(MyVariable))
Marshal.StructureToPtr(MyVariable, data.lpData, True)
SendMessage(hwndTarget, WM_COPYDATA, Me.Handle, data)
MsgBox("WM_COPYDATA")
Exit Function
If Not System.IntPtr.Zero.Equals(hwndTarget) Then
Call PostMessage(hwndTarget, MessageId, 0, 0)
MsgBox("Message sent")
Else
MsgBox("Unable to send Message ! probably GLOBAL_IDENTITY_TWO Not found")
End If
End Function
Public ReadOnly Property ONE_TO_TWO_MESSAGEID() As IntPtr
Get
Static objONE_TO_TWO_MESSAGEID As IntPtr
If IntPtr.Zero.Equals(ONE_TO_TWO_MESSAGEID) Then
objONE_TO_TWO_MESSAGEID = RegisterWindowMessage(MESSAGE_FOR_TWO)
End If
Return objONE_TO_TWO_MESSAGEID
End Get
End Property
#End Region
Region "dispose method and new()/constructor"
Public Sub Dispose() Implements IDisposable.Dispose
If Not Me.Handle.Equals(IntPtr.Zero) Then
Me.ReleaseHandle()
End If
End Sub
Public Sub New()
Dim Params As CreateParams = New CreateParams
Params.Caption = GLOBAL_IDENTITY_ONE
Me.CreateHandle(Params)
End Sub
#End Region
End Class
--------------------------------------xxxxxxxxxxxxxxxxxxxxxxxxxx----------------------------------
----this is class two-listening to message-----------
Imports System.Runtime.InteropServices
Public Class clsIPC
Inherits System.Windows.Forms.NativeWindow Implements IDisposable
Private Const GLOBAL_IDENTITY_ONE = "GLOBAL_IDENTITY_ONE"
Private Const GLOBAL_IDENTITY_TWO = "GLOBAL_IDENTITY_TWO"
Private Const MESSAGE_FOR_ONE = "MESSAGE_ONE"
Private Const MESSAGE_FOR_TWO = "MESSAGE_TWO"
Private Const WM_COPYDATA As Integer = &H4A
Private Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" _
(ByVal lpString As String) As IntPtr
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As IntPtr, ByVal wParam As Integer,ByVal lParam As Integer) As IntPtr
<structlayout(layoutkind.sequential)> _
Private Structure CopyData
Public dwData As IntPtr
Public cbData As Integer
Public lpData As IntPtr
End Structure
Structure PT
Dim x As Object '<<<----- whenever i use object as member of a structure i get an exception An unhandled exception
'of type 'System.ExecutionEngineException' occurred in mscorlib.dll if i use string as a
'member there is no error
Dim y As Integer
Dim xy As Integer
End Structure
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_COPYDATA
Dim data As CopyData
Dim message As String
Dim MyPoint As New PT
data = CType(m.GetLParam(GetType(CopyData)), CopyData)
MyPoint = Marshal.PtrToStructure(data.lpData, GetType(PT)) <<<---- @ this point i'm getting the error [debug]
'MyPoint = Marshal.PtrToStructure(CType(m.GetLParam(GetType(CopyData)), CopyData).lpData, GetType(PT))
MsgBox(CType(MyPoint.x, String))
Case TWO_TO_ONE_MESSAGEID().ToInt32
MessageBox.Show("GOT A MESSAGE FROM ONE--- CALLING METHOD A", "VBNETMessaging")
Call A()
End Select
MyBase.WndProc(m)
End Sub
Private Sub A()
MsgBox("Message from Method A")
End Sub
Public ReadOnly Property TWO_TO_ONE_MESSAGEID() As IntPtr
Get
Static objTWO_TO_ONE_MESSAGEID As IntPtr
If IntPtr.Zero.Equals(objTWO_TO_ONE_MESSAGEID) Then
objTWO_TO_ONE_MESSAGEID = RegisterWindowMessage(MESSAGE_FOR_TWO)
End If
Return objTWO_TO_ONE_MESSAGEID
End Get
End Property
#Region "dispose method and new()/constructor"
Public Sub Dispose() Implements IDisposable.Dispose
If Not Me.Handle.Equals(IntPtr.Zero) Then
Me.ReleaseHandle()
End If
End Sub
Public Sub New()
Dim Params As CreateParams = New CreateParams
Params.Caption = GLOBAL_IDENTITY_TWO
Me.CreateHandle(Params)
End Sub
#End Region
End Class
--------------------------------------xxxxxxxxxxxxxxxxxxxxxxxxxx----------------------------------
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
Can I ask why you're try to pass data the hard way, instead of using .NET Remoting?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
actually the request is sent by an AddIN to the application-software.
what i have to do is to pass an object from addins to software-app.
If you can solve this then good even if you can solve in remoting well i've got no probs.
-thanks
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
If you're writing both the software and the add-in's, Remoting is the best way to go!
If I'm sounding like I'm guessing what your trying to do, it's because I am. You haven't povided any detail about what your ultimate goal with this code is, besides transferring a pointer through a Window message. Why are you doing this? How does this little piece fit into the "grand scheme" of things?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
i'm not using remoting coz i've a little time to accomplish this task. well, actully i dont know remoting.
Now about my "Grand Scheme", using this if any-how i can pass the object of the office-application to another application-sw, the work is done. One more thing, I have succesfully sent the structure to the "other end", but whenever Object comes in the picture an error occurs:-
An unhandled exception of type 'System.ExecutionEngineException' occurred in
mscorlib.dll
Now thats the problem. Well I'll do try with remoting but it'll take some time, which i dont have now.
-thanks buddy
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
I don't have a lot of time right now, so I can't put a project together to test what your doing. All I can suggest at this time is you might want to take a look at this: The Quick and Dirty Guide to .NET Remoting[^]
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
ok thnks for your help .. I'll contact you as soon as i finish this off.
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
Hi all,
i am trying to make a client and server application (using sockets) that allow client to upload image files from client machine to server machine.
i am using file stream and network stream to do that.
but the new file always coruppted .
here is my code:-
on client side:- it is a console application, in main function:-
Const portNo = 500
Const FILE_NAME = "c:\image1.tif"
Dim tcpClient As New System.Net.Sockets.TcpClient
tcpClient.Connect("Localhost", portNo)
Dim NWStream As NetworkStream = tcpClient.GetStream
Dim numBytesRead As Integer
Dim bytesToSend(1024) As Byte
Dim fs As FileStream
fs = New FileStream(FILE_NAME, FileMode.Open, _
FileAccess.Read)
Do While fs.ReadByte <= fs.Length
numBytesRead = fs.Read(bytesToSend, i, bytesToSend.Length)
NWStream.Write(bytesToSend, i, numBytesRead)
Loop
fs.Close()
Console.WriteLine("Sending ...")
Console.ReadLine()
tcpClient.Close()
on the server:- main function
Const portNo As Integer = 500
Dim listener As New TcpListener(CType(Dns.Resolve("Localhost").AddressList(0), IPAddress), portNo)
listener.Start()
Console.WriteLine("Listening...")
Dim tcpClient As TcpClient = listener.AcceptTcpClient()
Dim NWStream As NetworkStream = tcpClient.GetStream
Dim buffer(1024) As Byte
Const FILE_NAME = "c:\image2.tif"
Dim fs As System.IO.FileStream
fs = New FileStream(FILE_NAME, FileMode.CreateNew, _
FileAccess.Write)
Do Until (NWStream.DataAvailable = False)
NWStream.Read(buffer, 0, buffer.Length)
fs.Write(buffer, 0, buffer.Length)
Loop
fs.close()
tcpClient.Close()
listener.Stop()
Console.ReadLine()
may be code is not correct !!! i am new to socket programming, so please help me .
any comment will be very helpfull
thanks in advanced..
shelal
|
|
|
|
|
There are LOTS of problem with this code. The most obvious is that your compairing a byte read from the file to the length of the file! Why? By doing this, you're more than likely truncating your reading of the file, so that's a source of corruption.
Do While fs.ReadByte <= fs.Length
Now, you've read a byte from the file and didn't do anything with it, then you read more bytes into the buffer, ignoring the byte you already read and dropped(!). There's another source of corruption.
numBytesRead = fs.Read(bytesToSend, i, bytesToSend.Length)
Now, in your server code, you're indidscriminately writing blocks of 1024 bytes to your image file, completely ignoring who many bytes were actually read from the stream! You have to determine how many bytes were read from the stream so you can only write than many bytes to the file! Without that, especially at the end of the file, you'll be writing more than was actually sent to you. Another source of corruption...
Do Until (NWStream.DataAvailable = False)
' How many bytes were read here??
NWStream.Read(buffer, 0, buffer.Length)
' How many are you writing here??
fs.Write(buffer, 0, buffer.Length)
Loop
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How i can devide two number in the same text field and return the result
the operation is 30/20 this is in the textbox1 then i need the result 1.5
Amarni
|
|
|
|
|
you'll have to split the string first using some form of delimiter (an operator perhaps), parse them, perform the calculation and then return the result.
|
|
|
|
|
i know that.. but how could i use this way ??????
and id the user make an error like this 30//10 or 30/10/
so what is the solution for this problem
Amarni
|
|
|
|
|
Try to split the text then call divide function.
Dim num() As String = txtInput.Text.Split(CChar(vbTab))<br />
'//Throw number to function<br />
Divide(num(0), num(1))
Hope this help.
|
|
|
|
|
hello can anyone helop me by telling how to make a connection class and how to work with stored procedures in vb.net.
Mohinder Singh
|
|
|
|
|
How about following up on the replies in the previous thread[^] instead of asking the same question again?
---
b { font-weight: normal; }
|
|
|
|
|
can u please tell me how to that thing
Mohinder Singh
|
|
|
|
|
Go to your profile and click on "Messages Posted". There you will find the messages you wrote, and you can view the previous thread.
---
b { font-weight: normal; }
|
|
|
|
|