|
Plenty of info here[^]. Ideally you will write a seperate data layer that handles all your database calls. A book on ADO.NET is what I'd recommend here.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi everyone.
Hoping for some clarification how the error provider and the "validating" event works on a form, because what I am experiencing doesn't seem very user friendly for the end user.
In a nutshell, once the control FAILS my conditions in the "validating" event and I issue the e.cancel command, focus returns to the failed control and I cannot move the focus until the control has a valid entry.
Why is this bad ? For example, consider a textbox that accepts a file system directory path, and a browse button next to it. I want the advanced users to be able to type (using autocomplete) the path and basic users to be able to use the browse button. However once the textbox has the focus, any attempts to click on the browse button fail as the focus cannot move from the textbox that just failed validation.
Now I have read a lot of articles, and it appears the error provider doesn't normally exhibit this behaviour. Am I right ?? If it is not normal, any ideas what might cause this ??
- I have a form with a tabcontrol that has several pages
- I have an error provider on the form
- All bound controls reference the same bindingsource
- initially the error provider had a datasource of the bindingsource. I removed it and still nothing.
Here is one of the pieces of code:
Private Sub txtClientBaseFilePath_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtClientBaseFilePath.Validating
Dim IsError As Boolean = False
'check if the string is not null using the basic textbox validation
If IsTextBoxEmpty(txtClientBaseFilePath, strErrorPathNotSpecified & strErrorPath) = True Then
IsError = True
Else
'check if the patch exists. if not exist then offer to create the path
Try
If My.Computer.FileSystem.DirectoryExists(txtClientBaseFilePath.Text) = False Then
If MessageBox.Show("Directory does not exist. " & vbCrLf & vbCrLf & "Would you like to create the directory?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.Yes Then
My.Computer.FileSystem.CreateDirectory(txtClientBaseFilePath.Text)
SetStatusLabel("Directory '" & txtClientBaseFilePath.Text & "' created successfully", False)
Else
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathMustExist)
IsError = True
End If
Else
'directory exists OK
End If
'catch errors such as creating path fails due to rights, invalid path, etc
Catch ex As ArgumentException
'The directory name is malformed. For example, it contains illegal characters or is only white space (ArgumentException Class).
'The directory name is Nothing (ArgumentNullException Class).
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathInvalidCharacters & strErrorPath)
SetStatusLabel("Directory creation failed - " & strErrorPathInvalidCharacters, True)
IsError = True
Catch ex As IO.PathTooLongException
'The directory name is too long (PathTooLongException Class).
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathTooLong & strErrorPath)
SetStatusLabel("Directory creation failed - " & strErrorPathTooLong, True)
IsError = True
Catch ex As IO.IOException
'The parent directory of the directory to be created is read-only (IOException Class).
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathReadOnly & strErrorPath)
SetStatusLabel("Directory creation failed - " & strErrorPathReadOnly, True)
IsError = True
Catch ex As NotSupportedException
'The directory name is only a colon ( . (NotSupportedException Class).
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathNotSupported & strErrorPath)
SetStatusLabel("Directory creation failed - " & strErrorPathNotSupported, True)
IsError = True
Catch ex As UnauthorizedAccessException
'The user does not have permission to create the directory (UnauthorizedAccessException).
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathNoRights & strErrorPath)
SetStatusLabel("Directory creation failed - " & strErrorPathNoRights, True)
IsError = True
Catch ex As Security.SecurityException
'A partial-trust situation exists in which the user does not have sufficient permissions (SecurityException).
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathNoRights & strErrorPath)
SetStatusLabel("Directory creation failed - " & strErrorPathNoRights, True)
IsError = True
Catch ex As Exception
Throw ex
IsError = True
End Try
End If
If Not IsError Then
Me.epSystemSettings.SetError(txtClientBaseFilePath, "")
End If
e.Cancel = IsError
End Sub
|
|
|
|
|
Thinking about it I guess it is behaving as expected. ie: when leaving the control the validating routine runs and when it fails the action to move elsewhere is aborted through the e.cancel.
So with this in mind I have moved the code to different events such as "TextChanged" and "Leave" BUT for some reason the errorprovider only displays on some occasions rather than all. Typically on the first time I enter an invalid value (such as blank ""), the errorprovider doesn't display but if I create the same error it displays.
This validation stuff is driving me Nuts !!!!
What do you guys normally do to validate a whole bunch of controls on a page ? I would have thought validating field by field was more user friendly than waiting til the end and doing it, but as described in my example sometimes it isn't practical to force a user to stay on the control.
|
|
|
|
|
With help from this and other forums, ihave be able to make a countdown timer.
Now what i would like to do is make the programs window Flash when the counter has reached ZERO.
can anybody steer me in the right direction.
THANKS
|
|
|
|
|
Flash in what way ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I don't really care, "in what way" as long as it stands out.
|
|
|
|
|
Well, to change the title bar, you may be able to set a color property, but I suspect you'd have to owner draw. To flash things on the form, is far easier. Just set a timer to fire and alternate some colors. Kill it after a particular number of iterations.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I wouls love to alternate some colours, as of yet have not figure out how to do it.
what i have in my timer_tick is...
me.background = color.yellow
Is there a way to randomly select a .color
|
|
|
|
|
You can build an array and select from there, or select the red/green/blue components at random
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Yes, use a random class and three integers.
Dim Ran as new random<br />
dim R as integer = ran.next(0,255)<br />
dim G as integer = ran.next(0,255)<br />
dim B as integer = ran.next(0,255)<br />
<br />
me.backgroundcolor = color.fromargb(r,g,b)
Your getting three random numbers, rgb values, and making a color out of it.
|
|
|
|
|
Hello!
I have a 'Panel' and have placed differnt RTF text boxes and differnt locations on the Panel. I can drag these text boxes, at runtime, anywhere on the panel. What i want is: When i press the "Print" button all the RTF text within "RTFTextBoxes" should be printed to paper exactly at the location where Text Box is located on the Panel.
My core problem is how can i print RTF text from each individual RTB at specified location.
Thank you for any help!
colgateas900197
|
|
|
|
|
|
Another possibility would be to drop a Form Print Component[^] on your form and set the extended properties e.g. Print to True, BoundingRectangle to whereabouts on the page you want it to appear, and set RTFPrintMethod to print out the rich text box in what-you-see-is-what-you-get ...
|
|
|
|
|
Sir i m trying with an challanging asigmnent to work with editing textfiles in vb6.0 i had file which looks as below :
Color|Fruits|series|IN|OUT|NET|VAL|
Black|Mango |001|1000|2000|-1000|1.5|
white|banana|001|100 | 20| 80|1.5|
white|cherry|001|1000|1000| 00|1.5|
Black|almond|001| 20| 80| -60|1.5|
i m trying to get data and save in seperate file which in below format :
COLORS,FRUITS,NET,(+/-QTY)
B ,BANANA,20,1
W ,ALMOND,60,2
Here following conditions should me matched
1) NET column sholud be greater than 0 and less than 100 also less than -1 and greater than -100 but should not be 0
2)select only fruit column and color column from previoustext file
plz provide me guidance as soon as possible i m stuck with this problem thank u
JACK
|
|
|
|
|
Do your own homework.
Paul Marfleet
|
|
|
|
|
Why are people being taught VB6 ? You may as well raise your kids to speak Latin. Except no-one will think you're stupid for knowing Latin.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi all
First off im a student, but this is Not an assignment, it's the end of degree project!.. so im kinda freakin out a bit.
i dont want a handout, just a point in the right direction.
Ive built this application, like a floorplan viewer that has network devices on the map, works great, but now my business client wants to make it distributed, and run it as a service.
i have used a previous chatroom that i built to use for a test case, to see if i could host a remoting server in a service. the chatroom works fine its very simple, which is why i thought it would be a good test for using remoting in a service. for the test case (and confidentialy) ive decided its better to post this chatroom that i converted to a service instead of the real app.
The problem is the same with both the chatroom and the floorplan app,
1. the service starts fine, creates proxy, a successful event log is written.
2. start the client, proxy created, then on the first proxy method call i get this error...
************** Exception Text **************
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'ClientGUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'ClientGUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Reflection.MemberInfoSerializationHolder..ctor(SerializationInfo info, StreamingContext context)
=== Pre-bind state information ===
LOG: User = NT AUTHORITY\SYSTEM
LOG: DisplayName = ClientGUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/chat/MyService/bin/Release/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI.DLL.
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI/ClientGUI.DLL.
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI.EXE.
LOG: Attempting download of new URL file:///C:/chat/MyService/bin/Release/ClientGUI/ClientGUI.EXE.
--- End of inner exception stack trace ---
Server stack trace:
at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
at System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context)
at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(String objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel securityLevel)
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at SharedClasses.IServer.Connect(Parcel msgDel, Parcel usrDel, String userName)
at ClientGUI.ClientForm.btnConnect_Click(Object sender, EventArgs e) in C:\chat\ClientGUI\ClientForm.vb:line 41
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
ClientGUI
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/chat/ClientGUI/bin/Release/ClientGUI.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
SharedClasses
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/chat/ClientGUI/bin/Release/SharedClasses.DLL
----------------------------------------
the questions i guess i have are...
How do i tell it where to find the assembly?,
why does this not happen when it is not run as a service.. it works fine. i got good marks for it!
i really havent dealt with assemblys and namespaces (conciously) and this stuff, but keen as to figure this out.
Can anyone point me in the right direction?
Project code is below
Many thanks
red
|
|
|
|
|
Code for Service:
Imports System.Runtime.Remoting
Imports MyServer
Imports SharedClasses
Public Class MyService
Private proxy As Server
Protected Overrides Sub OnStart(ByVal args() As String)
RemotingConfiguration.Configure("C:\chat\MyService\bin\Release\ServerForm.config", False)
proxy = CType(Activator.GetObject(Type.GetType("SharedClasses.IServer, SharedClasses"), "tcp://localhost:8085/yakkityYak"), SharedClasses.IServer)
Dim objEventLog As New EventLog()
objEventLog.Source = "MyService"
objEventLog.WriteEntry("proxy created")
'StartTimer()
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
End Sub
End Class
Code for Server:
Imports SharedClasses
Public Class Server
Inherits MarshalByRefObject
Implements IServer
Private htMsgDel As New Hashtable
Private htUsrDel As New Hashtable
Public msgDel As IServer.msgCallBack
Public usrDel As IServer.usrCallBack
Public Function Connect(ByVal msgParcel As Parcel, ByVal usrParcel As Parcel, ByVal userName As String) As Boolean Implements IServer.Connect
SyncLock GetType(Server)
Dim connected As Boolean
If Not htUsrDel.ContainsKey(userName) Then
htMsgDel.Add(userName, msgParcel.msgDel())
htUsrDel.Add(userName, usrParcel.usrDel())
BroadcastUsers(userName)
connected = True
Else
MsgBox("The username " & userName & " is not available.")
End If
Return connected
End SyncLock
End Function
Public Sub disConnect(ByVal userName As String) Implements SharedClasses.IServer.disConnect
SyncLock GetType(Server)
htMsgDel.Remove(userName)
htUsrDel.Remove(userName)
BroadcastUsers(userName)
End SyncLock
End Sub
Public Sub BroadcastUsers(ByVal senderName As String) Implements IServer.BroadcastUsers
Dim alUsers As New ArrayList
For Each userName As String In htUsrDel.Keys
If Not userName = "server" Then
alUsers.Add(userName)
End If
Next
For Each userName As String In htUsrDel.Keys
If Not userName = senderName Then
usrDel = htUsrDel.Item(userName)
usrDel(alUsers)
End If
Next
End Sub
Public Sub Message(ByVal msg As String, ByVal userName As String) Implements IServer.Message
SyncLock GetType(Server)
For Each user As String In htMsgDel.Keys
If Not user = userName Then
msgDel = htMsgDel.Item(user)
msgDel(userName & ": " & msg & vbCrLf, userName)
End If
Next
End SyncLock
End Sub
Public Function getUsers() As ArrayList Implements IServer.getUsers
Dim alUsers As New ArrayList
For Each userName As String In htMsgDel.Keys
alUsers.Add(userName)
Next
Return alUsers
End Function
Public Sub TickMessage(ByVal msg As String) Implements IServer.TickMessage
SyncLock GetType(Server)
For Each user As String In htMsgDel.Keys
If Not user = "server" Then
msgDel = htMsgDel.Item(user)
msgDel(msg & vbCrLf, user)
End If
Next
End SyncLock
End Sub
End Class
Code for Server config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="tcp" port="8085">
<serverProviders>
<provider ref="wsdl" />
<formatter ref="soap" typeFilterLevel="Full" />
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
<clientProviders>
<formatter ref="binary" />
</clientProviders>
</channel>
</channels>
<service>
<wellknown type="MyServer.Server, MyServer" objectUri="yakkityYak" mode="Singleton" />
</service>
<!-- <lifetime leaseTime="10S" sponsorshipTimeOut="10S" renewOnCallTime="5S"/> -->
</application>
</system.runtime.remoting>
</configuration>
Code for Client:
Imports System.Runtime.Remoting.Channels.ChannelServices
Imports System.Runtime.Remoting.Channels.TCP
Imports SharedClasses
Public Class ClientForm
Private IPAddress As String
Private userName As String
Private proxy As IServer
Public msgDel As IServer.msgCallBack
Public usrDel As IServer.usrCallBack
Private myConfiguration As Configuration
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click
If txtUserName.Text = "" Then
MsgBox("enter a user name please")
txtUserName.Focus()
ElseIf Not txtUserName.Text.Length <= 13 Then
MsgBox("user name must be 13 characters or less")
txtUserName.Focus()
Else
Dim chan As TcpChannel
chan = New TcpChannel(0)
RegisterChannel(chan, False)
proxy = Activator.GetObject(Type.GetType("SharedClasses.IServer, SharedClasses"), "tcp://localhost:8085/yakkityYak")
' Send message delegate
msgDel = AddressOf msgCallBack
Dim msgParcel As Parcel = New Parcel(msgDel)
usrDel = AddressOf usrCallBack
Dim usrParcel As Parcel = New Parcel(usrDel)
userName = txtUserName.Text
Try
Dim connected As Boolean = proxy.Connect(msgParcel, usrParcel, userName)
If connected Then
btn.Enabled = False
btnSend.Enabled = True
txtUserName.Enabled = False
Me.Text = "Client : " & txtUserName.Text
ToolStripConnect.Text = "Connected"
For Each user As String In proxy.getUsers()
If Not user = "server" Then
lstUserNames.Items.Add(user)
End If
Next
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If
End Sub
Private Sub ClientForm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Not proxy Is Nothing Then
proxy.disConnect(userName)
End If
End Sub
Public Sub usrCallBack(ByVal userNames As ArrayList)
lstUserNames.Items.Clear()
For Each user As String In userNames
lstUserNames.Items.Add(user)
Next
End Sub
Public Sub msgCallBack(ByVal msg As String, ByVal userName As String)
rtbMessages.AppendText(msg)
End Sub
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
If Not txtMessage.Text = "" Then
proxy.Message(txtMessage.Text, userName)
msgCallBack(userName & ": " & txtMessage.Text & vbCrLf, userName)
txtMessage.Text = ""
txtMessage.Focus()
End If
End Sub
Private Sub ClientForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
btnSend.Enabled = False
IPAddress = "localhost"
End Sub
Private Sub contextUser_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles contextUser.Opening
If Not lstUserNames.SelectedIndex = -1 Then
MsgBox(lstUserNames.SelectedItem.ToString)
End If
End Sub
Private Sub mnuConfiguration_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuConfiguration.Click
If myConfiguration Is Nothing Then
myConfiguration = New Configuration
End If
myConfiguration.Show()
End Sub
End Class
Code for serializable object
<Serializable()> Public Class Parcel
Private msgDelegate As IServer.msgCallBack
Private usrDelegate As IServer.usrCallBack
Public Sub New(ByVal del As IServer.msgCallBack)
msgDelegate = del
End Sub
Public Sub New(ByVal del As IServer.usrCallBack)
usrDelegate = del
End Sub
Public ReadOnly Property msgDel() As IServer.msgCallBack
Get
Return msgDelegate
End Get
End Property
Public ReadOnly Property usrDel() As IServer.usrCallBack
Get
Return usrDelegate
End Get
End Property
End Class
code for interface to server
Public Interface IServer
Delegate Sub msgCallBack(ByVal s As String, ByVal userName As String)
Delegate Sub usrCallBack(ByVal userNames As ArrayList)
Function Connect(ByVal msgDel As Parcel, ByVal usrDel As Parcel, ByVal userName As String) As Boolean
Sub disConnect(ByVal userName As String)
Sub Message(ByVal msg As String, ByVal userName As String)
Sub TickMessage(ByVal msg As String)
Sub BroadcastUsers(ByVal senderName As String)
Function getUsers() As ArrayList
End Interface
code for the server Gui ***** not used anymore, this is what the service is replacing... hopefully...
Imports System.Runtime.Remoting
Imports MyServer
Imports SharedClasses
Public Class ServerForm
Private proxy As New Server
Public msgDel As IServer.msgCallBack
Public usrDel As IServer.usrCallBack
Private Sub ServerForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mnuShutdown.Enabled = False
Timer1.Enabled = True
End Sub
Private Sub StartServerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuStart.Click
'configure server
RemotingConfiguration.Configure("ServerForm.config", False)
proxy = CType(Activator.GetObject(Type.GetType("SharedClasses.IServer, SharedClasses"), "tcp://localhost:8085/yakkityYak"), IServer)
'setup delegates
msgDel = AddressOf MsgCallBack
Dim msgParcel As Parcel = New Parcel(msgDel)
usrDel = AddressOf usrCallBack
Dim usrParcel As Parcel = New Parcel(usrDel)
'connect to proxy
Dim connected As Boolean = proxy.Connect(msgParcel, usrParcel, "server")
mnuStart.Enabled = False
mnuShutdown.Enabled = True
toolStripConnect.Text = "Server Started"
End Sub
Public Sub MsgCallBack(ByVal msg As String, ByVal userName As String)
rtbMessages.AppendText(msg)
End Sub
Public Sub usrCallBack(ByVal userNames As ArrayList)
lstUserNames.Items.Clear()
For Each user As String In userNames
lstUserNames.Items.Add(user)
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
proxy.TickMessage("sss")
MsgBox("x")
End Sub
End Class
thanks for your time
|
|
|
|
|
Solved... i didnt have a copy of the client in the servers folder, so as it said, ....FileNotFoundException... doh!
|
|
|
|
|
I have this question :
A gas pump calculates the cost of gas at a local gas station. The station charges 2.09 per gallon for regular grade gas, $2.16 per gallon for special grade gas and $2.26 per gallon for the super grade gas. The click event handler for each button calls a method to compute the total cost
from the number of gallons entered and the selected grade.
I have attempted this way :
Public Class FrmGasolineCalculator
Inherits System.Windows.Forms.Form
'Labels for the form are defined here
Friend WithEvents lblTitle As System.Windows.Forms.Label 'Title label
Friend WithEvents lblLabel1 As System.Windows.Forms.Label 'Label to prompt user input
Friend WithEvents lblLabel3 As System.Windows.Forms.Label 'Label to display the output
'Read one number from the user as an input
Friend WithEvents txtInput As System.Windows.Forms.TextBox
Friend WithEvents txtResult As System.Windows.Forms.Label 'Result will be displayed here
'Reads input and calculates result accordingly
Friend WithEvents btnRegular As System.Windows.Forms.Button
Friend WithEvents btnSpecial As System.Windows.Forms.Button
Friend WithEvents btnSuperplus As System.Windows.Forms.Button
Dim result As Decimal
Function Calculate(ByVal Total As Decimal) As Decimal
Dim Quantity As Integer = 0
txtInput.Text = Convert.ToInt32(Quantity)
Total = 0
Dim Cost As Decimal
Select Case Cost
Case 2.09
Total = Quantity * 2.09
Return Total
Case 2.16
Total = Quantity * 2.16
Return Total
Case 2.26
Total = Quantity * 2.26
Return Total
End Select
End Function
Private Sub Regular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Regular.Click
txtResult.Text = Convert.ToDecimal(result)
result = 0
If Not txtInput.Text = " " Then
result = Calculate(result)
End If
End Sub
End Class
I have not handled the other two buttons Special and Superplus because the programming will be the same.
Error is :
Object reference not set to an instance of an object. How to handle this ?
Thanks
|
|
|
|
|
Hi,
a couple of remarks:
1.
all errors show line numbers:
- compile errors mention file name and line number
- run-time exceptions show complete stack traceback with line numbers
2.
Visual Studio can be told to show line numbers in the left margin of the editor,
see Options/Tools/TextEditor
3.
combining 1 and 2, if something goes wrong you can easily determine where the error
occured.
4.
I have never seen cases with decimal values, but I doubt you need them.
What happened to TotalCost = Quantity * UnitCost ?
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi all
sorry to trouble you.
actually my problem is i have to split one large file into small files.
based on these conditions, i have maximum file size and minimum file size.
to split the large file into smaller ones,the child file should be either maximum size or greater than minimum size and less than maximum size.
iam struggling to write the logic,plese help me to write the logic.
suppose for example large filesize is 1050MB and max size is 100MB and minimmum size is 90MB.i have to split first as many as possible max size files and remaining are in between max and minimum size.
advancedly thanks to giving replies
Thanks&Regards
RENU
|
|
|
|
|
I remember answering the same question a while back. Search in the forum and see if you can find it.
---
single minded; short sighted; long gone;
|
|
|
|
|
Yes, tell your teacher/professor to give you different homework, since that one
can be found everywhere on the web.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I have created an application in vb .NET using ODBCConnection Object (for MS-Access). this is a MDI Application. when i am running this Exe thru the network it is showing following error-
[Request for the permission of type 'System.Data.Odbc.OdbcPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
Error in SQL Connection
I Want to solve this problem thru code in 'VB .NET'. I do not want to do this manually as we do from "Control Panel->adminstrative tool->MS .NET Framework2.0 Configuration" How can i solve this problem. Please help me.
my mail ID is kkb_mda@yahoo.co.in
Thanks and Regards
Kishore
|
|
|
|
|