|
is there other way..???
coz the program need to run in user group logon
your help is badly needed..
thanks..
Bitz
|
|
|
|
|
Then this registry value must be set by an Administrator. Users will not be able to do this. Something like this is normally done by the application's installer, which is always run by an Admin.
|
|
|
|
|
Dave Kreskowiak wrote: Something like this is normally done by the application's installer, which is always run by an Admin.
For very good reason, too.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
U can try this may be it will work. Run program in local user use operation "Run as" may be it wil work
|
|
|
|
|
non-bugging Errors wrote: Run program in local user use operation "Run as" may be it wil work
Quote Selected Text
As Dave mentioned, this can potentially ask for trouble doing so.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I have a DGV w/20 columns (4 hidden). The default column sort works fine except for one column which I would like to sort based on the value of a hidden column.
Primitive Example:
Column 5 = Cost (String)(visible)
"1 Apple"
"1 Apple, 2 Oranges"
"2 Oranges"
Column 20 = TotalCost (Integer)(hidden)
1
3
2
When the user clicks on the column for sorting I should display:
"1 Apple"
"2 Oranges"
"1 Apple, 2 Oranges"
Question: How do I intercept the sort event for a specific column and use a different field to sort the results?
|
|
|
|
|
Intercepting the event - oncolumnclick
Detecting the column clicked - e.index I think
custom sorting - you will probably need to write your own, I'd be surprised if there is not an article here already.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for the reply. I Implemented the following to solve it (using the fruit example):
<br />
Private Sub SortButton_Click(ByVal sender As Object, _<br />
ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseClick<br />
<br />
Dim hit As DataGridView.HitTestInfo = DataGridView1.HitTest(e.X, e.Y)<br />
If hit.Type = DataGridViewHitTestType.ColumnHeader Then<br />
If DataGridView1.Columns.Item(hit.ColumnIndex).Name = "Fruit" Then<br />
<br />
Dim oldColumn As DataGridViewColumn = DataGridView1.SortedColumn<br />
Dim newColumn As DataGridViewColumn = DataGridView1.Columns.Item("FruitCount")<br />
Dim direction As ListSortDirection<br />
<br />
' If oldColumn is null, then the DataGridView is not currently sorted. <br />
If oldColumn Is Nothing Then<br />
direction = ListSortDirection.Ascending<br />
Else<br />
' Sort FruitCount again, reversing the SortOrder.<br />
If Me.DataGridView1.SortOrder = SortOrder.Ascending Then<br />
direction = ListSortDirection.Descending<br />
Else<br />
direction = ListSortDirection.Ascending<br />
End If<br />
End If<br />
<br />
' Sort the grid based on FruitCount<br />
Me.DataGridView1.Sort(DataGridView1.Columns("FruitCount"), direction)<br />
DataGridView1.Columns("Fruit").HeaderCell.SortGlyphDirection = direction + 1 <br />
Else<br />
DataGridView1.Columns("Fruit").HeaderCell.SortGlyphDirection = SortOrder.None<br />
End If<br />
End If<br />
<br />
End Sub<br />
The other columns have autosort, so if the column I'm looking for is not selected (or any other random click) it just falls through to the default handlers. Also using column name instead of index since I allow the user to move (some) columns.
|
|
|
|
|
I would have thought you would use columnheadermouseclick as the initiating event?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Actually I did try that but I could never get e.ColumnIndex to return anything other than -1 although the event fired properly. Probably mis-coded it or maybe since I have fullrowselect on?
|
|
|
|
|
Hi everyone,
a problem with "{" character iun VB
Example
Dim sb As Text.StringBuilder = New Text.StringBuilder()
sb.AppendFormat("click(function()")
sb.AppendFormat("{") 'exception in this line
sb.AppendFormat("}") 'the same exception for this line
Console.WriteLine(sb.ToString())
exception {"Input string was not in a correct format."}
how can I correct it in VB
|
|
|
|
|
You didn't supply a Format specification to the AppendFormat method.
Since it's obvious that you're not out to format data when you put it in a string, change those AppendFormat methods to just Append .
Try reading the documentation on the StringBuilder class.
|
|
|
|
|
since { is a "special" character when it comes to formatting, the error you got is once for the fact that u didn`t supply a valid format and second because u didn`t supply any of the objects that need to be formatted. A minimum code change should be
sb.AppendFormat("{0:G}","}")
|
|
|
|
|
I'm writing a util that uses a hidden webbrowser control to traverse through a few .aspx pages. These are through an SSL enabled site. I want to accept the certificate and or install it locally instead of the end user clicking on "yes" to accept it. I've googled for quite some time and found 2 different methods. One for .NET 1.1 and .NET 2.0. I cannot get either to work. The dialog still pops up. I am trying to put this into a module. Here's what I have tried.
Imports System.Net
Imports System.Net.Security
Imports System.Security.Cryptography.X509Certificates
Imports System.Security.Policy
Module VWeb
Dim WithEvents WB As New WebBrowser
Dim ASPComplete As Integer = 0
Dim LoginURI As New Uri("https://XXX.com/Login.aspx")
Dim OpenCallsURI As New Uri("https://XXX.com/openCallReport.aspx")
Dim MainPage As New Uri("https://XXX.com/Default.aspx")
Dim TestTimer As New Timer()
Public Function LoginAsTech(ByVal UserID As String, ByVal Pass As String) As Boolean
Dim MyDoc As New mshtml.HTMLDocument
Dim DocElements As mshtml.IHTMLElementCollection = Nothing
Dim LoginForm As mshtml.HTMLFormElement = Nothing
ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
ASPComplete = 0
WB.Navigate(LoginURI)
BrowserLoop()
MyDoc = WB.Document.DomDocument
DocElements = MyDoc.getElementsByTagName("input")
For Each i As mshtml.IHTMLElement In DocElements
Select Case i.name
Case "seLogin$UserName"
i.value = UserID
Case "seLogin$Password"
i.value = Pass
Case Else
Exit Select
End Select
frmServiceCalls.txtOut.Text &= i.name & " : " & i.value & " : " & i.type & vbCrLf
Next i
'WB.Document.Forms("form1").InvokeMember("submit")
LoginForm = MyDoc.forms.item("form1")
LoginForm.item("seLogin$LoginButton").click()
ASPComplete = 0
BrowserLoop()
MyDoc = WB.Document.DomDocument
DocElements = MyDoc.getElementsByTagName("input")
For Each j As mshtml.IHTMLElement In DocElements
frmServiceCalls.txtOut.Text &= j.name & " : " & j.value & " : " & j.type & vbCrLf
Next j
frmServiceCalls.txtOut.Text &= vbCrLf & vbCrLf & WB.Url.AbsoluteUri & vbCrLf
Return 1
End Function
Public Sub BrowserLoop()
Do Until ASPComplete = 1
Application.DoEvents()
Loop
End Sub
Private Sub WB_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WB.DocumentCompleted
ASPComplete = 1
frmMain.tsProgress.Visible = False
frmMain.lblProgress.Text = ""
End Sub
Private Sub WB_Navigating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WB.Navigating
frmMain.tsProgress.Visible = True
frmMain.lblProgress.Text = "Navagating"
End Sub
Public Sub WB_ProgressChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WB.ProgressChanged
frmMain.tsProgress.Maximum = Convert.ToInt32(e.MaximumProgress)
frmMain.tsProgress.Value = Convert.ToInt32(e.CurrentProgress)
End Sub
Public Function ValidateCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As Security.SslPolicyErrors) As Boolean
'Return True to force the certificate to be accepted.
Return True
End Function
End Module
Method 1 - This method is for the .NET 1.1 framework. I'm using 2.0. Tried it anyways with no luck.
frmMain_Load Event()
ServicePointManager.ServerCertificateValidationCallback = New CertPolicyOverride
Imports System.Net
Imports System.Security.Cryptography.X509Certificates
Public Class CertPolicyOverride
Implements ICertificatePolicy
Public Function CheckValidationResult(ByVal srvPoint As ServicePoint, ByVal cert As X509Certificate, ByVal request As WebRequest, _
ByVal certificateProblem As Integer) As Boolean Implements ICertificatePolicy.CheckValidationResult
'Return True to force the certificate to be accepted.
Return True
End Function
End Class
Method 2 - Tried putting ServicePointManager line in the frmMain_Load event, didn't work. Tried in the module before "navigating" call. Tested the same. I also tried ValidateCertificate in both frmMain and in the module as well.
ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
Public Function ValidateCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As Security.SslPolicyErrors) As Boolean
'Return True to force the certificate to be accepted.
Return True
End Function
I've tried a few ways and I've been trying off and on for about 2 weeks. Finally came to the message boards for help. I'm starting to wonder if it has to do with the WebBrowser class. I was trying to stay away from WebRequest and HttpWebRequest. I find it really easy to process these web pages and javascript utilizing the WebBrowser control. I need to click a button or checkbox here and there and I would rather let the WebBrowser handle the background stuff like .aspx/javascript callbacks, realtime combo box updates etc... Things that are processed as you go. Any Takers??
Thank you,
Joe G.
|
|
|
|
|
You still can process the output of webrequest or httpwebrequest with webbrowser control using WebBrowser.DocumentStream property ... so for test purposes make the request with a webrequest and redirect the incoming stream to documentstream property.
Additionally ServicePointManager serves for managed code usage, while webbrowser is a wrapper around the shdocwhatever.
|
|
|
|
|
The answer from sph3rex is an entirely valid one, however if you still want to do it using your hidden window I have a solution that will assist you. It is part of an article detailing various WebBrowser/Security 'tricks' that I have employed that I am currently writing up. It should be published here on Code Project shortly (i.e. in the next week) and I will notify you when it is ready.
BimJeam
|
|
|
|
|
I look forward to it. I'm sure it will help others. I'm experimenting with the DocumentStream property. So far it's been ok. Not getting what I wanted but still tweaking about. Thanks.
|
|
|
|
|
|
I'm trying to do the checksum calculations on data received via RS232, but the specification for the data doesn't explain the calculation algorith very in-depth. I tried researching the algorithm but my results always differ from the expected checksum.
Here is the spec's decription of the checksum calculation:
Sum modulo $FFFF of all characters from position two of the data and up to the last
character prior to the checksum identifier character. Value is a 4-byte hexadecimal number
preceded by space. Hex number is represented as a lowercase ASCII hex.
The reason it only starts at byte 2 is because byte 1 is the STX character.
This text file's[^] contents should easily calculate to the checksum (which is the last 4 bytes of the text). This text doesn't include the first byte (the STX) as it as already been stripped off by the handshaking.
(Sorry for using that crappy site for the file upload, my normal filesharing site is down today)
I'm using vb6 and would appreciate any help or pointer that could steer me in the right direction.
|
|
|
|
|
Let's see the checksum implementation you've got. It's really hard to come up with their implementation is they don't describe exactly how THEY interpreted "checksum".
|
|
|
|
|
This is what I have so far, still not getting the correct checksum:
Dim MsgToCalc As String
Dim DataBytes() As Byte
MsgToCalc = Left(msg, Len(msg) - 6) '6 Because the space and y character befor the checksum is also excluded
CheckSum = Right(msg, 4) '4 Because the checksum is 4 bytes long
'Create an array of DATABYTES for MsgToCalc
ReDim DataBytes(0 To Len(MsgToCalc) - 1)
DataBytes = StrConv(MsgToCalc, vbFromUnicode)
Dim Str16 As String
Dim Total As Long
Dim MyChecksum As Long
Dim SubTotal As Integer
Dim i As Integer
i = 0
' The following is an attempt to do the calculations at this link:
' http://www.cs.tut.fi/~dunaytse/wireshark-2306/lab2.pdf
' Still not sure why they get a negative checksum from 1's compliment
For i = 0 To (Len(MsgToCalc) - 1)
If i Mod 2 = 0 Then
Str16 = CStr(Hex$(DataBytes(i))) & CStr(Hex$(DataBytes(i + 1)))
SubTotal = Val("&H" & Right(Str16, 4))
Total = Total + SubTotal
Total = Val("&H" & Right(Hex$(Total), 4))
MyChecksum = 65535 - Total
End If
Next i
My calculated checksum is D3E8 and it's supposed to be 6676
I'm following THIS PAGE[^] for my calculations but I must be doing something wrong!
Regards
|
|
|
|
|
OK, this implementation, ummm, well, all the string handling makes this, probably, the most inefficient algorithm I've seen. Hex$() returns a string, so all the CStr's around them are redundant. On top of that, you're using the most convoluted method of string manipulation to do simple math with two bytes. All your string code is really doing this: SubTotal = Byte(0) * 256 + Byte(1) .
Now, the last line is removing a compounded total from 65535. Well, in most cases, that's going to be a negative number. That's something that doesn't exist in a checksum.
You REALLY have to know the implementation being used. If the manufacturer hasn't told you, you're just guessing. Since you don't know which algorithm to use, nor do you know how to implement one, I'd suggest using a library that supports a bunch of different algorithms and try each until you either find one that works, or find out which algorithm they're using. Try this library...[^]
|
|
|
|
|
Dave Kreskowiak wrote: the most inefficient algorithm I've seen
I don't really have any good excuses to cover for me here, I never really work with binary maths in VB6 so I guess I was just lazy.
But to find the algorithm I tried probably a 100 different combinations of which none of them is an exact hit. That little bit of text in the OP is the only info from the manufacturer and I'm guessing getting hold of them could be hard since the programnmers are probably in the USA and I'm in South Africa and this is a very old model of the instrument.
Dave Kreskowiak wrote: Now, the last line is removing a compounded total from 65535. Well, in most cases, that's going to be a negative number. That's something that doesn't exist in a checksum.
This was "my way" of doing a MOD FFFF on the total. I wanted to do it with Total MOD Val("&H" & "FFFF") method, but since VB6 assumes I'm using 1's compliment, it returns a negative number. Is there a better way to do that?
Thanks for the library, I'll give it a shot!
|
|
|
|
|
Chksum calculation depends on the data which is received from your rs232 port. first u have to know which type of checksum calculation id doing in the source(unit/hardware).
some standard hardwares/units follow the standard checksum calculation. line crc-8bit,16-bit..etc... (U will get more info. from GOOGLE.).
am sending a code from my project code , how to calc the crc-16bit checksum.
Public Function crcbits16(ByVal str As String)
Dim crc As UShort = &HFFFF
Dim ser_data
crc = &HFFFF
Dim i As Long, p As Long
i = str.Length
For p = 0 To i - 1
ser_data = str.Substring(p, 1)
crc = (crc >> 8) Or (crc << 8)
crc = crc Xor Asc(ser_data)
crc = crc Xor (crc And &HFF) >> 4
crc = crc Xor (crc << 8) << 4
crc = crc Xor ((crc And &HFF) << 4) << 1
Next
Return CRCFormat(Hex(crc))
End Function
--------------------------------
Public Function CRCFormat(ByVal mycrc As String)
If Len(mycrc) < 4 Then
mycrc = Replace(Space(4 - Len(mycrc)) & mycrc, " ", "0") '"0" & mycrc
End If
End Function
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
Thank you for responding.
Fatal Error wrote: crc = (crc >> 8) Or (crc << 8)
What does this code do? (I get the shift but not the "OR", Var = x or y )
How should I rewrite it to work in VB6?
|
|
|
|