|
Don't cross post.
"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
|
|
|
|
|
hi,
i have a server that using tcplistener and define client as tcpclient,
my client is a hardware that convert tcp connection to rs232 connection,
everything fine but after my server application have a problem and crash, it dont close the tcpclient properly where it can be close in my stop server button event, when i open again my server application, it dont detect that client, so, is there any solution to close the tcp client when i load up my application, or something that force etect the client..
im confuse now...
|
|
|
|
|
Hi,
IMO restoring the communication between a client and a server is a client responsibility, the server
could/should not care.
The same is true when the human user uses a browser to visit a website on some server.
So what I would do is implement a timeout/delay/retry mechanism at the client.
The main choice to make now is: lazy connection or eager connection, i.e. should the client
make/restore a connection when it needs to communicate or as soon as possible (which would be
based on a ping-like interrogation of the server).
|
|
|
|
|
Hello,
I am new to WPF and I want to learn it as fast as I can :P i can't wait to give these new 3D effects to the applications I want to create. I found this cool 3d flip feature in this site
http://www.interact-sw.co.uk/iangblog/2007/05/17/wpf-flippable-3D-list[^]
Its purely made in XAML, but i know we can use Visual Studio 2008 and VB.NET to create effects like these... i tried to look for any kind of a tutorial on the net but i didn't get any which could teach me flipping controls in WPF windows in this manner.
If anyone could help me out I would be grateful
thank you
|
|
|
|
|
Maybe if you posted in this[^] forum, you will get the information you are looking for...
|
|
|
|
|
hey thank you.. i didn't realize there might be a different forum for wpf . thanks a ton and sorry for posting in the wrong forum... this was my first post :P
|
|
|
|
|
I have a project that normally loads an activex control. However, if the control isn't available an error is created "...encountered a problem and needs to close". Is it possible to get around this and let the program run even without the control?
Thanks
|
|
|
|
|
cstrader232 wrote: Is it possible to get around this and let the program run even without the control?
Yes, but any dependency on the control in other parts of the program will crash on you. why not ensure the control is always going to be available?
"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
|
|
|
|
|
Yes, I understand that I cannot use the control if it's not loaded.
The problem is that some users will not have installed the 3rd party software that supplies the control.
I could I suppose install and register it for them but I don't want to do that because I'm then modifying a control that might be used by still other programs.
Right now, my program looks for the registered control with the appropriate name, because that is what has been added to the form. But if another program modifies or deletes that control, then my program is in trouble.
Is it possible to link a specific control to my program from a specific file at runtime -- ideally without having to register it which could cause problems elsewhere?
Thanks!
|
|
|
|
|
I recalled a greater value than the number of field devices and pagers assigned to the variable ..
Then I've written code design programmatically within a button for ..
I apply fully with me .. But the interface problem .. Come:.
When I click on the button is doing a certain ..
Settled happened button _click and Manf ..
You Code:.
Public WithEvents B As Button
Dim sql_tim As String = "select max(pc_no) from pc "
cmd_pc.Connection = con
cmd_pc.CommandText = sql_tim
n = cmd_pc.ExecuteScalar
====================
Dim x, y,i
x = 269
y = 44
For i = 1 To n
B(i) = New Button
B(i).Location = New System.Drawing.Point(x, y)
B(i).Name = "b" & i
B(i).Size = New System.Drawing.Size(101, 103)
B(i).TabIndex = i
B(i).Text = "open" & i
B(i).UseVisualStyleBackColor = True
B(i).Image = Global.server.My.Resources.Resources.op
B(i).Image = Global.server.My.Resources.Resources.col
B(i).ContextMenuStrip = Me.ContextMenuStrip1
Controls.Add(B(i))
x = x + 130
If i Mod 6 = 0 Then
x = 269
y = y + 120
End If
Next
ــــــــــــــــــــــــــــــــــــــــــــــــــــ
Private Sub B_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1.Click
Msgbox("welcom")
End Sub
Required:.
All are doing a certain button for example, show a message ..
|
|
|
|
|
Hey? What? Errmmm, not at all sure what you are saying or what problem you are experiencing and need help with.
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
I wrote a "widget" to report sales data, etc. I need to make some calculations based on business days to date this month. Business days are Mon-Fri, minus any holidays. Holidays are defined in my.settings, using a string collection. The function below iterates through the days of the current month until it reaches today. For each iteration, it checks to see if the day is a weekday, then checks to see if it is listed in my.settings.holidays. If it is a weekday, and not a holiday, the counter is incremented. If it is a holiday I receive a message "Holiday". This works exactly as I expect on my dev machine. However, when running the widget on any other machine, the "IF" statement that checks the holidays never evaluates to true. Any ideas anybody? Am I missing an import statement?
Protected Overridable Function CountBusinessDays() As Integer
Dim BusDays As Integer
Dim RefMonth As Integer = Month(Now)
Dim CalcDate As Date = DateSerial(Year(Now), Month(Now), 1)
Do While Month(CalcDate) = RefMonth
Dim wkday As Integer = Weekday(CalcDate)
If wkday <> 1 And wkday <> 7 Then
If Not My.Settings.Holiday.Contains(CalcDate.ToString) Then
BusDays = (BusDays + 1)
Else : MsgBox("Holiday") 'For testing....
End If
End If
If CalcDate = Date.Today Then Exit Do
CalcDate = CalcDate.AddDays(1)
Loop
Return BusDays
End Function
We use Visual Studio 2005, and have .Net framework 3.5 installed on all machines.
|
|
|
|
|
How is your 'Holiday' setting originally getting populated? I am wondering if maybe the string you expect simply is not in the User.Config on the "other" machine(s). Have you checked the user.config on the other machines to see if that setting is populated?
|
|
|
|
|
Excellent thing to check. However, I have already checked that the holidays are there. The 'Holidays' are pre-populated with some default values at build time. The user can change them at will. The settings are there, I verified this with:
For each st as string in My.Settings.Holidays
msgbox(st)
Next
The messages show the correct dates, which reflect any changes made on the specific machine. I also
have user settings for fore and back colors, window location, etc. which are always applied correctly.
I also tried aggregating all the holidays into one string and search it using 'InStr'. Once again, this worked fine on the dev machine but not others.
Does the problem lie in the fact that I am comparing a "date.tostring" with a "string"? But it does work on the dev machine....
|
|
|
|
|
Does the problem lie in the fact that I am comparing a "date.tostring" with a "string"? But it does work on the dev machine....
That may very well be the problem, since the 'ToString()' can do a default conversion to different formats on different machines. Since you know what the date format used is within the 'Holiday' setting, you should ensure that you convert to that format with ToString. For example, if your Holiday date string format is YYYYMMDD, you could do CalcDate.ToString("yyyyMMdd") in your conditional statement.
|
|
|
|
|
Thanks! That is it. I had tried '.toshortdatestring' and a few others, and none worked. For some reason I never thought of simply formatting the string.
|
|
|
|
|
I have been working on this code for quite awhile and cant seem to get it right. Its supposed to worked like
1. Click button to load csv(appended to datagrid1)
2. Click another button to export the edited csv.(not working at all, not sure where to start)
currently my datagrid codes are
<br />
button load_csv click<br />
Dim strConnection As System.Data.OleDb.OleDbConnection<br />
Dim myPath As String = "c:\testing.csv"<br />
<br />
Try<br />
<br />
'Dim objDataSet As System.Data.DataSet<br />
Dim objAdapter As System.Data.OleDb.OleDbDataAdapter<br />
<br />
strConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source='" & myPath & " '; " & "Extended Properties=Excel 8.0;")<br />
objAdapter = New System.Data.OleDb.OleDbDataAdapter("select * from [sheet1$]", strConnection)<br />
objDataSet = New System.Data.DataSet<br />
objAdapter.Fill(objDataSet)<br />
DataGrid1.DataSource = objDataSet.Tables(0).DefaultView<br />
strConnection.Close()<br />
<br />
Catch ex As Exception<br />
<br />
Dim er As String<br />
<br />
strConnection.Close()<br />
<br />
End Try
i believe i do have to declare a global variable for datagrid1 as the export function needs it.
modified on Monday, July 28, 2008 2:03 PM
|
|
|
|
|
zzsoulzz wrote: Click another button to export the edited csv.(not working at all, not sure where to start)
Provide your code for this part, the other code you provided looks right. Is it populating the datagrid?
"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
|
|
|
|
|
yes it is populating for my datagrid1
here is the code for export to csv
Dim dataSource As DataTable = DirectCast(DataGrid1.DataSource, DataTable)<br />
<br />
Dim currentRow As New System.Text.StringBuilder<br />
Dim entireFile As New System.Text.StringBuilder<br />
<br />
'Write the column names as headers for the file<br />
For Each column As DataColumn In dataSource.Columns<br />
currentRow.Append(""""c & column.ColumnName & """"c & ",")<br />
Next<br />
<br />
'Add the current line to the entire file StringBuilder<br />
entireFile.Append(currentRow.ToString)<br />
<br />
'Write each data row to the file StringBuilder<br />
For rowIndex As Int32 = 0 To dataSource.Rows.Count - 1<br />
currentRow = New System.Text.StringBuilder<br />
For Each column As DataColumn In dataSource.Columns<br />
currentRow.Append(""""c & dataSource.Rows(rowIndex)(column.ColumnName).ToString & """"c & ",")<br />
Next<br />
entireFile.Append(currentRow.ToString)<br />
Next<br />
<br />
'Write the contents of the entireFile StringBuilder to a file.<br />
Dim sw As New System.IO.StreamWriter("C:\Temp\DataGrid.csv")<br />
<br />
sw.Write(entireFile.ToString)
|
|
|
|
|
Why not open the file in the beginning and just write the lines one at a time? Is the StreamBuilder creating the csv data correctly?
"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
|
|
|
|
|
having that code allows others to input their own csv instead of specifying one.
the current export isnt exporting at all.
it returns
<br />
An unhandled exception of type 'System.InvalidCastException' occurred in BScanner.exe<br />
<br />
Additional information: Specified cast is not valid.<br />
for this line
Dim dataSource As DataTable = DirectCast(DataGrid1.DataSource, DataTable)
|
|
|
|
|
Hi,
I'm not a VB 2005 coder. I'm forced to use VB because the SDK that came with a device only supports VB.
I have to send 65536 floating values to this device. I store these values in a double array and when I need to send them to the device I use stringbuilder in a thread to build the string, as following.
For i = 0 To 65535
System.Threading.Thread.Sleep(1)
ArbString.Append(", ")
ArbString.Append(ArbData(i).ToString("0.0000"))
worker.ReportProgress(i)
Next
Despite using stringbuilder the whole takes around 40 seconds to complete. Am I doing something wrong here or is there something I can do to speed the whole thing up?
TIA
|
|
|
|
|
shortest time you can sleep is 13 ms if i recall correctly.
so 65536 * 13 = 851 sec if Im not too tired after my vacation :P
|
|
|
|
|
Hi,
1.
you can't get an accurate delay like that. Sleep causes a thread switch, and it could take any
number of milliseconds before your thread is allowed back in.
for more accurate timing stuff, you may want to read my timers article.
2.
if you want to measure StringBuilder.Append performance, make a loop that contains just that;
no threading stuff, no backgrounders, no GUI access. Loop it many many times and use a StopWatch
to measure it. (BTW my article does not mention StopWatch, it was based on NET 1.x and StopWatch
got introduced with 2.0; I am working on an update).
3.
If you want maximum StringBuilder performance, make sure it has sufficient capacity right from
the start. If you don't, it will outrun its capacity, allocate a new and larger buffer
(typ. twice as large) and copy what it had so far. Your example needed around 500K characters, so
about two megabytes of unnecessary data copying have occured. Of course, using string instead of
StringBuilder would have been much much worse.
|
|
|
|
|
Hi Luc,
Thanks for your effort.
1. The sleep(1) is there todo just that, to give other threads a chance to get some execution time in the scheduler.
2. I didn't measure it using any timers, just the watch on my wrist. The thing is I did build a nice little GUI around this whole process with a nice animation and a progressbar but it still seems weird to me that this whole process would take so much time to complete.
3. You might be onto something there, how do I preallocate the size of a stringbuilder?
|
|
|
|