|
The best way (given the limited explanation you have), would be a lookup table. Store the ID and the object it belongs to, or the object type, in some structure. Trying to create an object to "see if it works" is probably the worst way you can go about this.
|
|
|
|
|
OK great, thanks for your help.
|
|
|
|
|
Liqz wrote: I thought of having, in the database table, an owner (ID?) field and an owner type field (this seems the best way so far).
You thought correctly, it enables you to lookup the type based on the OwnerID without storing duplicates
It is dangerous to instantiate something that you do not know - since it might, for example, delete all records in a table on startup, as initialization. Even if you're sure that nothing can go wrong, then it would still be slow, as you already stated.
Liqz wrote: what is the best way to determine the owner? i.e. what type of object.
If you can't ask the owner-object itself, then you'll have to resort to keeping track of that information elsewhere. Like tracking it in a database
I are troll
|
|
|
|
|
Hi guys....
i have tried many ways to do this and have googled and searched msdn but to no avail.
i want my client app.exe to check app.exe on the server.
if the server app.exe is of a new version then the client app.exe to copy and overwrite itself.
the reason for this is i have many client pc's at a site.
i simply want to drop the latest app.exe on the server and whenever a client app.exe is launched then it should do the above check.thus the client app.exe is always the latest app.
this is my code below.
Dim objFSO As New Object
Dim objLocalFile, objServerFile As New Object
Dim dtmLocalDate, dtmServerDate As New Object
Const OverwriteExisting = True
'COPY FILE
objFSO = CreateObject("Scripting.FileSystemObject")
objLocalFile = objFSO.GetFile(My.Settings.LocalFile.ToString.Trim)
dtmLocalDate = objLocalFile.DateLastModified
objServerFile = objFSO.GetFile(My.Settings.ServerFile.ToString.Trim)
dtmServerDate = objServerFile.DateLastModified
If dtmLocalDate > dtmServerDate Then
objFSO.CopyFile(objServerFile.Path, objLocalFile.Path, OverwriteExisting)
'OR
'My.Computer.Network.DownloadFile("\\Server\app.exe", "C:\client\app.exe", "domain\username", "Password", True, 10000, True)
End If
the error i get is....
"The system detected a possible attempt to compromise security. Please ensure that you can contact you server that authenticated you."
thanks
Anoop
|
|
|
|
|
You need to write a seperate app that does the check and downloads a new .EXE. You cannot overwrite an .EXE that's already running, so it has to be done by a seperate app.
And why on earth are you using the FileSystemObject when all of it's functionality and WAY MORE, can be found in the System.Io namespace in the .NET Framework??
|
|
|
|
|
hi,
using FileSystemObject cos i was not able to download the file usind my.computer.network.download.
i was just trying different options.
yes,
i have created a seperate app to check both versions before overwrite, however im still getting the same error, with network authentication.
thanks
|
|
|
|
|
I have no idea what's going wrong with your setup. The original code you had does work, so it's got to be something in your network's setup that you don't know about that's causing the failure. I already told you how to specify the username with the domain the user account is in, so there's something else you have to talk to your network people about to get the answer. What's causing the problem is specific to your network environment.
|
|
|
|
|
|
hi...
modified 28-Nov-12 8:34am.
|
|
|
|
|
Hi,
this smay help
Dim objFSO, objFile, objDoc, PrevLine, CurrLine, lp
objFSO = CreateObject("Scripting.FileSystemObject")
objFile = objFSO.OpenTextFile("C:\Stock.txt", 1)
PrevLine = ""
lp = 0
'open the textfile
Do Until objFile.AtEndOfStream
'read the line
objDoc = objFile.ReadLine
'store the 1st line in a temp var
CurrLine = objDoc
'skip the 1st entry
'insert your code here that does the comparison, dfn and baloon
If ((CurrLine <> PrevLine) And lp &<> 0) Then
'write your output here
MsgBox(CurrLine)
End If
'increment the line counter
lp += 1
'make the 2nd var = 1st var line
PrevLine = CurrLine
Loop
objFile.Close()
hope this helps
thanks anoop
|
|
|
|
|
|
Hi
you need to update the variable currentpart,dfn,baloon to the nextpart,dfn,baloon when completed the comparison.
If ((currentLine <> previousLine) And (count <> 0)) Then
If (NextPart = currentPart And currentDNF = NextDNF And currentBaloon = NextBaloon) Then
sw.WriteLine(currentPart & count)
End If
End If
currentpart = nextpart
currentdfn = nextdfn
currentbaloon = nexboloon
count = count + 1
hope this helps
|
|
|
|
|
Do While currentPart = name
temp = sa.ReadLine()
name = temp.Substring(0, pF(1))
error on line "name"
the reference to the object does not have an instance of that object...
I you see my first Meaasge, you will find these lines...
Not sure about the error message
|
|
|
|
|
I have an oddity.
In Excel VBA I can access the content of a ComboBox as sDataExample = ComboBox1.Value having typed sDataExample as a string, and that is good.
IN VB I am trying to assign the selected item in the combobox to a string.
sDataExample = ComboBox.ValueMember() and it is not returning a string to sDataExample.
(It appears to be null).
How do I get the selected ComboBox Item into sDataExample as a string?
------------------------------------
"I am always serious about what I do, not necessarily about how I do it."
Tom Baker
|
|
|
|
|
ComboBox.Text should do it if your combo box is populated with strings.
ValueMember() is used when binding data to the combo box, it specifies what property to use as the value of the combo box item.
|
|
|
|
|
Hot Dammit!
Of Course!
I had a brain malfunction.
Thanks.
------------------------------------
"I am always serious about what I do, not necessarily about how I do it."
Tom Baker
|
|
|
|
|
There is method to read grayscale image as a 2 dimensional matrix in VB?
|
|
|
|
|
What would you like to do?
Convert an image from color to grayscale? Or something else?
|
|
|
|
|
No.I need to read image pixels which range from 0-255 and then encrypt these values using on e of the substitution techniques.
|
|
|
|
|
Since VB doesn't support pointers, the only method you have is GetPixel. Look into writing the image manipulation code in C#, which does support pointers, and convert the data into a form that VB can use.
|
|
|
|
|
I'm a complete noob so nobody laugh. I am just trying to put a rectangle on the form. When I debug the form loads, paints, the rectangle appears. About 5 seconds later another copy of the rectangle shows up in the wrong place and mostly cut off. If I resize it disappears. It looks like the same size rectangle but positioned at the top left corner of the screen instead of the top left corner of the form. Here is my entire code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Refresh()
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim BorderWidth As Integer
Dim TitleHeight As Integer
Dim PenWidth As Integer = 2
BorderWidth = SystemInformation.FrameBorderSize.Width
TitleHeight = SystemInformation.CaptionHeight
Dim bluebrush2 As New Drawing.Pen(Color.Blue, PenWidth)
e.Graphics.DrawRectangle(bluebrush2, 3 + PenWidth, 3 + PenWidth, Me.Size.Width - 8 - (BorderWidth * 2), Me.Size.Height - 8 - (BorderWidth * 2) - TitleHeight)
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Me.Refresh()
End Sub
End Class
|
|
|
|
|
Hi,
When a form gets a new size (including gets maximized), but also when it gets minimized, the Resize event will fire. When minimizing, the Form's location and size will be fake, which is fine most of the time. However, you have a Refresh() inside the Resize() handler, I have never seen that before, and it doesn't make sense to me. Windows by itself will fire a Paint event if there is a need, typically when you enlarge, uncover, restore or maximize the form, but not when you minimize it. So I suggest to remove the Refresh().
remark: if you put a Panel on the Form, and anchor it to the 4 edges of the form (you can use Visual Designer to add, postion and anchor the Panel), you then can paint in that Panel's Paint handler instead of the Form's Paint handler; the advantage then is you don't have to account for the border width, the caption height, etc. All the coordinates inside the Panel's Paint handler are relative to the top left of the Panel.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I got rid of the Resize event code and the form load code. As you suggested. I will certainly work toward the panel. However it's still doing the same thing. It draws the rectangle where it belongs and then 5 seconds later draws another one in the wrong place.
|
|
|
|
|
Hi,
I just noticed you got another Refresh(), this one inside the Load handler. Throw it out!
Although once more I don't understand how that could possibly paint outside of your Form, it should not be there at all.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
SeanTWard wrote: BorderWidth = SystemInformation.FrameBorderSize.Width
TitleHeight = SystemInformation.CaptionHeight
Dim bluebrush2 As New Drawing.Pen(Color.Blue, PenWidth)
e.Graphics.DrawRectangle(bluebrush2, 3 + PenWidth, 3 + PenWidth, Me.Size.Width - 8 - (BorderWidth * 2), Me.Size.Height - 8 - (BorderWidth * 2) - TitleHeight)
What's with all the borderWidth, titleHeight, and other junk?? Why could you just get the ClientSize dimensions of the form using Me.ClientSize?? It's everything without the titlebar and border widths.
|
|
|
|
|