|
I think you have left out some things in your description. Setting the datatable reference to Nothing destroys the table, colums, data, everything. You cannot reuse that object. Now you're saying you WANT to reuse the datatable and its columns, but no data. Which is it??
Coding123456 wrote: my properties need to reference the same datatable (which contains data or I set to Nothing indicating no data) to make sense of the data and the program needs to reference the same class.
Coding123456 wrote: If the datatable happens to be disposed (as it contained no data) as in your example I would get an error when I reference it.
These two things are mutually exclusive. You cannot have it both ways. I think you need to rethink this data model.
|
|
|
|
|
Dave Kreskowiak wrote: I think you have left out some things in your description. Setting the datatable reference to Nothing destroys the table, colums, data, everything. You cannot reuse that object. Now you're saying you WANT to reuse the datatable and its columns, but no data. Which is it??
Setting the datatable to Nothing I agree it will destroy the table. Which is fine as I don't want to reuse it's columns or data. I just want to be able to test if the datatable is Nothing and if so run some code. Or sometime later when if it does contain data, run different code.
To put it a different way, if dt is nothing I know there is no data associated with it, otherwise I can read data from the datatable. I am using its 'nothingness' as a flag
Thanks for your comments to date I appreciate your interest. I realise that I may use one word that inadvertently changes the the exact meaning of what I am trying to describe.
|
|
|
|
|
Coding123456 wrote: Using .NET apparently the garbage collector does not destroy the object as long as I don't go out of scope
Correction: The garbage collector will not destroy the object until all references to it are unreachable.
Coding123456 wrote: For example, if an object is set to Nothing inside a procedure and the next line of code creates an object of the same name, the first object may not yet be destroyed and a reference to the new object might incorrectly return the first object
I have no idea what the name property on an object has to do with anything, unless there is some pooling going on somewhere which is keyed on the name property. If there was it should be well documented.
Setting the reference to Nothing makes it unreachable (so long as there are no other references to it.)
If the object implements the IDisposable interface then you should, as a matter of good practice, call Dispose on the object.
Coding123456 wrote: I'm not entirly comfortable with this approach as it seems bad to set it to nothing if I actually intend to reuse it again and again.
I don't see a problem with that. If you set it to nothing and there is a consirerable amount of time before assigning new data then do so because in the intervening time the Garbage Collector can get it. If it is the very next statement where you assign data I don't really see much point.
|
|
|
|
|
Hi Colin, you say that
Colin Angus Mackay wrote: Setting the reference to Nothing makes it unreachable (so long as there are no other references to it.)
If the object implements the IDisposable interface then you should, as a matter of good practice, call Dispose on the object.
When I set the datatable to Nothing I am making the data unreachable which is what I want to do and it also gives me a condition I can test for to control program flow i.e. if dt is nothing then...
I don't want to dispose it as I may want to do something like this;
If dt is nothing then
return "Default Name"
else
return cstr(dt.rows(0).item("Name"))
end if
Colin Angus Mackay wrote:
I don't see a problem with that. If you set it to nothing and there is a consirerable amount of time before assigning new data then do so because in the intervening time the Garbage Collector can get it. If it is the very next statement where you assign data I don't really see much point.
So you are saying when I set the dt=nothing the data it pointed to will get cleaned up and dt still hangs around safely for me to reuse. This is reasssuring.
The time to assign new data may be immediate or after some time. It is really not the very next statement I have just simplified the code.
Thanks for your reply
|
|
|
|
|
Coding123456 wrote: I don't want to dispose it as I may want to do something like this
Eh?! You've already made it unreachable, you can't dispose something that is unreachable, you have to wait until the Garbage Collector does it for you. I think you seem to misunderstand what the Dispose method is doing.
Some classes implement the IDisposable interface which gives you a Dispose method. If a class gives you a Dispose method then you MUST as a matter of good practice dispose the object BEFORE making it unreachable. If you don't then the garbage collector will have to clean up the additional mess for you. If a class implements Dispose it is effectively saying "I make a bit of a mess, but I can clean up after myself". You do not want the Garbage Collector calling Dispose for you. Ever!
Coding123456 wrote: So you are saying when I set the dt=nothing the data it pointed to will get cleaned up and dt still hangs around safely for me to reuse
dt is a reference to something. The data that was referenced to it will be cleaned up by the Garbage Collector when there are no more references to it (i.e. it becomes unreachable). You can safely assign another object to dt and it will refer to the new object.
|
|
|
|
|
I would like to check if it is true that both the listener and the client must be in the same file but different class to work? I try separating them as 2 just as i wan to put each in 2 separate CPU and it seen to have some error on the client side.
i Dim client as new tcpclient they underline it as error.
|
|
|
|
|
No, you can have them both in the same file, same class, different files, different classes, partial classes, ... whatever. They'll still work.
Subjugate wrote: i Dim client as new tcpclient they underline it as error.
Probably because you're missing Imports or you haven't specified the entire fully qualified name of your TcpClient class.
|
|
|
|
|
So i would like to ask if u have any example of tcplistener and tcpclient both as stand alone application to pass me? As i can only find file that combine them together online. I need to test them out on 2 seperate pc before i can progress in my project. Thanks for the help.
|
|
|
|
|
i had downloded the c# project of html to pdf conversion, that uses the itextsharp.dll, but pdf file is not open.
so is there any other way of conversion
can anyone help me.
thanx and regards.
Gauri
|
|
|
|
|
There's tons of libraries you can buy.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Attempting to write a script that searches and moves .pst files from network share then merges them into the users exchange mailbox under a subfolder (ie Archives > myarchive1 etc). We simply wish to run this as a scheduled task.
The following is not mine (thanks to the author) but needs some modifying and comments added.
Appreciate the help!
--------------------
Function GetStorePath(strStoreID)
Dim intStart
Dim intEnd
Dim strProvider
Dim strPathRaw
intStart = InStr(9, strStoreID, "0000") + 4
intEnd = InStr(intStart, strStoreID, "00")
strProvider = Mid(strStoreID, intStart, intEnd - intStart)
strProvider = Hex2ToString(strProvider)
Select Case LCase(strProvider)
Case "mspst.dll", "pstprx.dll"
If Right(strStoreID, 6) = "000000" Then
'2003
intStart = InStrRev(strStoreID, "00000000") + 8
strPathRaw = Mid(strStoreID, intStart)
GetStorePath = Trim(Hex4ToString(strPathRaw))
Else
'97
intStart = InStrRev(strStoreID, "000000") + 6
strPathRaw = Mid(strStoreID, intStart)
GetStorePath = Trim(Hex2ToString(strPathRaw))
End If
Case "msncon.dll"
intStart = InStrRev(strStoreID, "00", Len(strStoreID) - 2) + 2
strPathRaw = Mid(strStoreID, intStart)
GetStorePath = Trim(Hex2ToString(strPathRaw))
Case "emsmdb.dll"
GetStorePath = "Exchange store"
Case Else
GetStorePath = "Unknown store path"
End Select
End Function
Public Function Hex4ToString(Data)
Dim strTemp
Dim strAll
Dim i
For i = 1 To Len(Data) Step 4
strTemp = Mid(Data, i, 4)
strTemp = "&H" & Right(strTemp, 2) & Left(strTemp, 2)
strAll = strAll & ChrW(Eval(strTemp))
Next
Hex4ToString = strAll
End Function
Public Function Hex2ToString(Data)
Dim strTemp
Dim strAll
Dim i
For i = 1 To Len(Data) Step 2
strTemp = "&H" & Mid(Data, i, 2)
strAll = strAll & ChrW(Eval(strTemp))
Next
Hex2ToString = strAll
End Function
|
|
|
|
|
Noone is going to write your code for you. If you've got a specific question, we can help with that.
This looks like really, really OLD VB5 or 6 code. You'd be much better off scrapping this and starting from scratch, using the Outlook automation libraries to do this.
|
|
|
|
|
Was not expecting someone else to rewrite anything.
Can you point me to the Outlook Automation library? I do have junior experience with C# and would prefer to code it in this as my VB skills a rusty.
Cheers!
|
|
|
|
|
Add a Reference to the Microsoft.Office.Outlook Primary Interop Assemblies. Or, you could add a reference to the COM Outlook library.
|
|
|
|
|
Hi all.
I hope I am not repeating a past question...well I had see replies to similar questions online but they never seem to provide a complete answer.
Basically I am wanting to control a stepper motor from the parallel port to turn a capacitor for an antenna.
So I am working through the code slowly adding as I go...well that's the plan ( a learning experience ).
Outputting to the port seems ok but wanting to stop the motor in the middle of loop.
So going back to basics just have a form, 2 buttons ( Run , Stop ) the loop begins when the Run is clicked.
But here is the question , how to stop and exit the loop on the click of the Stop button, I cant get focus to that button.
So to keep it simple, if just using a simple (For-next loop) what code is needed to solve my problem.
using VB 2005 express...
Thank you in advance....
John
|
|
|
|
|
The solution is to move the code that outputs the signal to the parallel port (a bad choice BTW) in another thread. They way you have it run now, it's impossible to stop the loop because no your loop is blocking all other code from running on the UI thread. This means that no events are getting processed, like the Click handlers.
Your other solution is to not use a loop. You can use a Timer to fire off a Tick event that icrements your motor one step. Then, you can stop the timer any time you want.
|
|
|
|
|
Hi..
Thanks Dave for that Idea using the Timer, I seem to have something that works...untested as far as driving the motor ....but reading the Lpt1 port indicates the info is getting where it should.
John
|
|
|
|
|
Hi,
I doubt a PC-based solution will ever be satisfactory. A PC (more accurately Windows) is not a real-time system, hence you will not be able to get the step times sufficiently accurate and constant (or accurately ramping up and down) so the motion will be erratic, and so will the sound be that your stepper motor is going to produce.
The right solution requires a microcontroller that takes care of the stepping; in such a solution the PC is used for the user interface, and passing high-level commands (such as stepping frequency, number of steps) to the microcontroller, which has to execute the steps with accurate timing.
As an added bonus, the interface becomes much simpler: instead of connecting the motor to the PC, the only thing connected to the PC now is a low-energy microcontroller, possibly through an RS232C serial port or something similar.
|
|
|
|
|
Hi
Thanks for the quick replies..
The stepper will have reduction gears so the steps will be very very small.
Type of steps will be added later with other things...as I say..working slowly and trying to learn.
I will look at the timer idea though..not sure how to work it but experimenting works..
John
|
|
|
|
|
Hi John,
reduction gears tell me the motor steps will be many, so my accurate timing concerns remain.
Good luck anyway.
|
|
|
|
|
Hi Luc
There is going to be buffering after the LPt1 port.
As long as it moves the motor in very small steps....I think all should be ok.. ( The cap works not so bad now with just a DC motor and reduction gear..I just want a bit more control..
John
|
|
|
|
|
Hi,
I am developing an application for Windows Mobile Pro 6. I realized that a picturebox's GotFocus and LostFocus events are not functioning. I tested it with the code shown below. Neither msgboxes popped up nor mousemove event got fired up but just click event. I have developed this Mobil App. under Windows Vista 64. What would be the reason for such problem? THANX.
Private Sub PictureBox5_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox5.GotFocus
MsgBox("Gotfocus") 'not working
End Sub
Private Sub PictureBox5_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox5.LostFocus
MsgBox("LostFocus") 'not working
mtt.Dispose()
End Sub
'the below procedure suppose to fired up when we go over the picture by mouse but it is fired up when I click the picture
Private Sub PictureBox5_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox5.MouseMove
Call ToolTip("Hello World", sender)
End Sub
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Are you sure you've got the mouse on PictureBox5??
|
|
|
|
|
Dear all
I am having xml file that look as below
<people>
<person id="001">
<name> ABC </name>
<age> 16 </age>
</person>
<person id="002">
<name> XYZ </name>
<age> 26 </age>
</person>
<person id="003">
<name> AAA </name>
<age> 26 </age>
</person>
</people>
Now i want to read every name and age from the xml file.
The code used as
Dim XMLDoc As New DOMDocument30
Dim NodLst As IXMLDOMNodeList
Dim Node As IXMLDOMNode
Dim Nod As IXMLDOMNode
Dim nodCnt As Long
Dim Data() As String
XMLDoc.async = False
'Loading the XML file on C drive
If XMLDoc.Load("D:\XML\123.xml") Then
'==========================
'Assigning root node to the node list variable
Set NodLst = XMLDoc.selectNodes("/People")
ReDim Data(NodLst.length)
For nodCnt = 0 To NodLst.length - 1
Set Nod = NodLst(nodCnt).selectSingleNode("Person")
Data(nodCnt) = Nod.Text
Set Nod = NodLst(nodCnt).childNodes(0)
'===========================
'Appending data inside "from" to "to"
Data(nodCnt) = Data(nodCnt) & vbTab & Nod.Text
Text1.Text = nodCnt
Text3.Text = Data(nodCnt)
Next nodCnt
Else
MsgBox ("Can't load file")
End If
The result is
ABC () 16
where as i need Name="ABC" & Age="16"
Please help
Thanx in advance...!!!
Shazz here to help you...
|
|
|
|
|
It appears that you're relying on the Nod.Text property to format the field names and values for you. Don't. Just get the Name and Age values for each person and format the output string yourself.
|
|
|
|