|
Hi Sascha, let me explain better, my project is a Vernam chat and i need to have one single keys txt file that must remain synchronized in some way between broadcaster and receiver. When I send the message the key used must be deleted and who receives after decripting too. I thought at line numbers of string to identify the key location, but I am open to other solutions.The goal is synchronizing the two key files!
|
|
|
|
|
Imagine your OTP file is just a sequence of bytes (or ASCII characters if you like). The message you want to encrypt is 100 (ASCII) characters long. The sender reads the next 100 characters from the OTP file, encrypts the message and sends it. The receiver sees 100 encrypted characters and also reads the next 100 characters from the OTP file to decrypt the message. Both sender and receiver know the length of the message, so they can update the position from where to read the next OTP-characters by the same amount. No line numbers needed.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
That is a bad way to do it, and can lead to corruption of your files. A much safer option is to use two files, one for input and one for output. Read the input file and copy the content to the output, replacing the required characters in memory as you copy. When you have successfully copied all the data you can delete the input file, or rename it to save as backup. You can then rename your output file to the original name of the input.
|
|
|
|
|
Good observation, but would be not preferable for a crypto chat read and write continuously wholly key file (size about 10 Mega) when just overwrite the first part of the file. I seek only a comfortable way to synchronize key file between broadcaster and receiver.
|
|
|
|
|
Fine, do it your way. But make sure you test your code to destruction before you use it on live data.
|
|
|
|
|
You could use a second file for just storing the position from where to read the next OTP-characters and leave the OTP-file unchanged.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Hi,
I have a fileupload control on a web form, along with an upload button and a radio button list of file types.
There exists the possibility that the user could click the upload button before selecting a file in the fileupload control which would generate an error message that would be displayed asking them to select a file first.
The issue is; if this situation occurs, the message remains on the screen, even after they select a file.
Is there some way to add a reset method to this control, so the previous error message gets cleared when the fileupload control is selected?
I tried a few things already and as you can probably guess, they all failed.
Red.
|
|
|
|
|
Yes, but it kind of depends on how you've implemented it so far. But basically add an onfocus (JavaScript) event to the fileupload control and in that clear the message - to do this you'd obviously need to first of all make sure its been written to a DOM element you can access.
|
|
|
|
|
Hello,
I am automating the website ("http://incometaxindiaefiling.gov.in/e-Filing/UserLogin/LoginHome.html") filling using vb6.
The code which works in IE10 & below is given here,
Dim WithEvents Web As SHDocVw.InternetExplorer
Private Sub Form_Load()
Set Web = New SHDocVw.InternetExplorer
Web.Visible = True
Web.Navigate "http://incometaxindiaefiling.gov.in/e-Filing/UserLogin/LoginHome.html"
End Sub
Private Sub Web_DocumentComplete(ByVal pDisp As Object, URL As Variant)
On Error GoTo aaa
msgbox " URL: " & URL
if url = "http://incometaxindiaefiling.gov.in/e-Filing/UserLogin/LoginHome.html" then
Web.Document.getElementById("Login_userName").Value = "abcde1111h"
Web.Document.getElementById("Login_userName").onchange
Web.Document.getElementById("Login_password").Value = "123456789"
Web.Document.getElementById("dateField").Value = "15/09/1954"
end if
Exit Sub
aaa:
MsgBox Err.Description & " URL: " & URL
End Sub
Private Sub Web_OnQuit()
MsgBox "OnQuit fired"
End Sub
In IE11 (Windows 10) I am facing the following problem with my code,
when navigated to above URL using SHDocVw.InternetExplorer control
First DocumentComplete event will be fired with URL being empty.
Then OnQuit event is fired. Then again DocumentComplete event is fired with URL 'about:blank'
When I run the exe with ‘Run as admin’ option then it works in IE11 without any errors.
Why in IE11 normal run is giving error ?
Please help.
|
|
|
|
|
Why are you using VB6? It was obsolete about 10 years ago!
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Good luck with that!
Trying to diagnose a problem with an application that has not been supported for over 10 years when running on the latest OS and browser is probably one of the most futile excercises I have heard of in quite a while.
You should have had a strategy to address this type of issue 10 years ago, now I suspect you are going to have to rewrite the web site with some urgency.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The time has come for you to get rid of VB6 and rewrite to .NET.
Good news = you can get free versions - see Visual Studio Express[^]
Better news = there are loads of articles around to help you achieve the rewrite in super-quick time e.g.
Internet Explorer Late Binding Automation[^]
Automation of Internet Explorer Using shdocvw.dll and mshtml.tlb – A Case Study[^]
But back to your original question...
The WebBrowser control stores it's recent history in a cache on the hard-drive. It's likely that IE11 is exercising greater control over access to certain folders, or rather greater adherence to the rules. You could check this out by using SysInternals ProcMon to monitor what is happening under the covers - Process Monitor[^]. (It's free and it's M$)
Obviously when running as Admin those areas of the hard disk become available.
You could try disabling the write to cache (caveat I have no means of testing this any more)
Web.Navigate "http://incometaxindiaefiling.gov.in/e-Filing/UserLogin/LoginHome.html", 8
|
|
|
|
|
i cant find and cant start to code how to calculate networkdays because i have no idea to do it. can someone help me? by giving me an example coding in calculating networkdays between two dates?
|
|
|
|
|
What are networkdays?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Ok. NetWorkDays[^] is an excel function to work out the number of working days between two dates, taking into account (optional) holiday dates provided.
There is this article on CodeProject - Excel NetworkDays for C#[^] ... yes, it's C# but there should be enough information there to get you started. Come back if you get stuck
[Edit - an alternative, sorry it's C# again] Business Dates Calculation[^]
|
|
|
|
|
Private Sub ttlLate()
Dim datardrr As MySqlDataReader
Try
conn.Open()
strSql = "SELECT dates between '" & dtpstart.Text & "' and '" & dtpend.Text & "', SUM(late) as SumTotalLate from tbl_attendance where employeeNumber='" & textempNoSrch.Text & "'"
cmd = New MySqlCommand(strSql, conn)
datardrr = cmd.ExecuteReader
TextLateDeduct.Text = datardrr("SumTotalLate").ToString
datardrr.Close()
conn.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
conn.Dispose()
End Try
End Sub
it gives me a 0 as output instead of 2.40. Late field is decimal in datatypes in mysql database.
|
|
|
|
|
I'm pretty sure you intend the "date-range" to be a WHERE-predicate, right? I don't know how exactly MySQL interpretes the statement that you have there currently; apparently it's no syntax error but it most certainly won't be interpreted as a WHERE-predicate.
Also you should use SQL-parameters (MySqlParameter in this case) instead of concantenating your SQL-statement. Concatenating values into the statement has several(!) disadvantages, the most prominent one being the risk of SQL-injection, potentially leading to inadvertant or purposeful destruction of your database (Google SQL-injection).
Also you should use using -statements for your MySql****-objects like the connection, command, datareader, etc., which will ensure those are properly disposed in any case.
Also I recommend to not keep any of those objects as class variables but only as local variables.
And since you only want one single value, you don't need a DataReader; instead you can execute your command with ExecuteScalar().
Dim startDate As DateTime
Dim endDate As DateTime
If Not DateTime.TryParse(dtpstart.Text, startDate) Then
End If
If Not DateTime.TryParse(dtpend.Text, endDate) Then
End If
Dim sql As String = "SELECT SUM(late) AS SumTotalLate FROM tbl_attendance WHERE employeeNumber=@empNo AND dates BETWEEN @startDate AND @endDate;"
Try
Using conn As New MySqlConnection(ConnectionString)
Using cmd As New MySqlCommand(sql, conn)
cmd.Parameters.AddWithValue("@empNo", employeeNumber)
cmd.Parameters.AddWithValue("@startDate", startDate)
cmd.Parameters.AddWithValue("@endDate", endDate)
conn.Open()
TextLateDeduct.Text = cmd.ExecuteScalar().ToString()
End Using
End Using
Catch ex As MySqlException
MessageBox.Show(ex.Message)
End Try
(I'm no VB.NET 'guy', maybe there's a small syntax error in there somewhere.)
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
modified 27-Mar-16 11:34am.
|
|
|
|
|
Dim startDate As DateTime
Dim endDate As DateTime
If Not DateTime.TryParse(dtpstart.Text, startDate) Then
' error indication and return
End If
If Not DateTime.TryParse(dtpend.Text, endDate) Then
' error indication and return
End If
Dim sql As String = "SELECT dates BETWEEN @startDate and @endDate, SUM( late ) AS SumTotalLate FROM tbl_attendance WHERE employeeNumber = @empno"
Try
Using conn1 As New MySqlConnection("server=localhost;userid=root;password=;database=amwps") ' ConnectionString from somewhere central
Using cmd As New MySqlCommand(sql, conn)
cmd.Parameters.AddWithValue("@empNo", TextEmpNo)
cmd.Parameters.AddWithValue("@startDate", startDate)
cmd.Parameters.AddWithValue("@endDate", endDate)
conn.Open()
Dim val As Integer = cmd.ExecuteScalar("SumTotalLate")
TextLateDeduct.Text = val.ToString()
End Using
End Using
Catch ex As MySqlException
MessageBox.Show(ex.Message)
End Try
sumtotallate can't display in textbox, it having an error "
No default member found for type 'DBNull'.
but when i've try it to my mysql localhost it gives accurate result. 2.40
|
|
|
|
|
Real Corks wrote: No default member found for type 'DBNull'. On which line does this exception occur?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Dim val As Integer = cmd.ExecuteScalar("SumTotalLate")
|
|
|
|
|
Apparently the result of the query is null (DBNull ) because there were no records matching the criteria. So your code attempted to assign DBNull to an Integer , which doesn't work. Try this:
Dim val As Object = cmd.ExecuteScalar("SumTotalLate")
If TypeOf val Is DBNull Then
TextLateDeduct.Text = "0"
Else
TextLateDeduct.Text = val.ToString()
End If
It will most certainly result in "0" being displayed, which, as you say, is not the result that you expect. But you also reversed the SQL command back to your first version, which, I think, is not correct. Did you try it with my modified SQL command?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
yes, i already tried your sql query but it gives me same output 0. Ok thanks, ill try to revised the sql query again. thanks
|
|
|
|
|
i am using vb.net and mysql database and creating crystal report using xml file.
<pre lang="VB.NET">
Private Sub ToolStripButton1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
conn.ConnectionString = "server=localhost;userid=root;password=;database=amwps"
If ToolStripComboBox1.SelectedItem = "Employee Information" Then
Dim daset As New DataSet
strSql = "SELECT * FROM tbl_employeeinfo"
conn.Open()
dadapter.SelectCommand = New MySqlCommand(strSql, conn)
dadapter.Fill(daset)
daset.WriteXml(CurDir() & "\xmlEmpSummary.xml", XmlWriteMode.WriteSchema)
conn.Close()
ElseIf ToolStripComboBox1.SelectedItem = "Attendance" Then
Dim daset As New DataSet
strSql = "SELECT * FROM tbl_attendance where dates = '" & ToolStripTextBox1.Text & "'"
conn.Open()
dadapter.SelectCommand = New MySqlCommand(strSql, conn)
dadapter.Fill(daset)
daset.WriteXml(CurDir() & "\xmlAttSummary.xml", XmlWriteMode.WriteSchema)
conn.Close()
ElseIf ToolStripComboBox1.SelectedItem = "Payroll" Then
Dim daset As New DataSet
strSql = "SELECT * FROM tbl_payroll where empNumber = '" & ToolStripTextBox1.Text & "'"
conn.Open()
dadapter.SelectCommand = New MySqlCommand(strSql, conn)
dadapter.Fill(daset)
daset.WriteXml(CurDir() & "\xmlPayrollSummary.xml", XmlWriteMode.WriteSchema)
conn.Close()
Else
MsgBox("Choose Filter!", MsgBoxStyle.Information, "Summary Report")
End If
End Sub</pre>
|
|
|
|
|
Do you plan to explain what the error is ?
Asking questions is a skill[^]
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
nothing error, my problem is it cannot create another xml file
|
|
|
|