|
Notice your Sub's last parameter declaration:
Sub DBINT4(... , ByVal W(,) As Double)
You told it to expect a 2 dimension array of Double's, but in your method calls somewhere else in your code, you passed in a single Double value for that parameter, not an array.
|
|
|
|
|
Yes, indeed, and that is perfectly valid in Fortran; rows (or was it columns ? dont remember)
follow one another.
And I expect it is hard to do the same in any CLR language; that's one more reason to
start from scratch.
|
|
|
|
|
OK I'm about to pull my hair out on this one. I've got a socket created that sends a network stream of data from a listview to an open port.
It works great!! I'm getting ACK's back from the server with no problem. I can even send multiple messages at a time. HOWEVER...
If I highlight one item and send it... then highlight another item immediately afterwards and send it... I get a connection refused.
If I send one item, wait about 7-8 seconds... then send another one... I'm fine.
Please review my code and tell me where I'm going wrong!! Thanks in advance!!
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim ListViewSelect As ListView.SelectedListViewItemCollection = Me.ListView1.SelectedItems
Dim item As ListViewItem
Dim selecteditem As String
Dim selecteditemhex As String = Chr(11)
Dim SelectedCount As String
Dim tcpClient As New System.Net.Sockets.TcpClient
Try
tcpClient.Connect("10.1.1.94", 8444)
'tcpClient.Connect("127.0.0.1", 8444)
Catch ex As Exception
MessageBox.Show(Err.Description)
End Try
SelectedCount = ListViewSelect.Count()
Select Case SelectedCount
Case 0
MessageBox.Show("Please select 1 item", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Case Is > 0
For Each item In ListViewSelect
selecteditem = selecteditemhex + LTrim(item.SubItems(4).Text)
Dim networkStream As NetworkStream = tcpClient.GetStream
If networkStream.CanWrite And networkStream.CanRead Then
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(selecteditem)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.ASCII.GetString(bytes)
MessageBox.Show("Host returned: " + returndata)
Else
If Not networkStream.CanRead Then
MessageBox.Show("cannot write data to this stream")
tcpClient.Close()
Else
If Not networkStream.CanWrite Then
MessageBox.Show("cannot read data from this stream")
tcpClient.Close()
End If
End If
End If
Next
End Select
btnSend.Text = "Sent"
tcpClient.GetStream.Close()
'tcpClient.Close()
End Sub
|
|
|
|
|
Hi,
I can not tell what is wrong just by looking.
One thing that strikes me is you have a lot of MessageBox statements, maybe one shows,
no matter what the flow in the method is. Wouldnt it then be better to close what needs to
be closed before you do a MessageBox ? (also it seems you sometimes do a GetStream.Close
after tcpCient.Close; dont know if that is wise). I think you could just set a string
variable (say "message") to the appropriate text, then go to the end of the method
where you close things and do the one and only MessageBox.Show(message).
If the above dont help, I would suggest you get more insight in the timing of your code:
what happens exactly when, and how long does it take. Therefore I would add some
timestamp logging statements.
Sorry but my examples will be in C# (I trust you'll know how to translate to VB):
private static void log(string s) {Console.WriteLine(DateTime.Now.ToString("mm:ss.fff ")+s);}
log("before connect");
tcpClient.Connect("10.1.1.94", 8444)
log("connected");
tcpClient.GetStream.Close()
log("tcp stream closed");
looking at the output you may discover that your code really takes several seconds to
execute, and maybe that there are opportunities to make it run a lot faster.
Hope this helps
|
|
|
|
|
By how many methods a class can be inherited in vb.net ?
|
|
|
|
|
Your question doesn't make any sense, but I'll take a guess at what you were trying to ask.
How many parent classes can a class inherit from? One and only one. But, a class can implement an unlimited number of Interfaces. Or do both at the same time.
|
|
|
|
|
I was confused too. I didn't know if he was asking how many instances of inheritance or how many methods to a class...
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
Since this is your first post I will not flame you, but you need to read the forum guidelines. Naming your message the same as the board gives us no clue as to what your problem is. You question may even be ignored in cases like this.
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
leckey wrote: question may even be ignored in cases like this
Which I am pretty much doing because the question makes no sense to me. What the frick is being asked here?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
I'm not sure if he's asking how many methods to one class or how many instances of inheritance of one class or...oh hell I don't know either!
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
leckey wrote: oh hell I don't know either!
I may add that to my ever growing list of sigs
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
The folowing is a Table and it's data of an MS Access Database
Table: EXPENSES
EDATE(Date) ETYPE(String) AMOUNT(Currency)
---------------------------------------------
01/01/07 Electricty 1000
21/01/07 Phone 1500
24/01/07 Repair 2000
05/02/07 Electricty 1000
23/02/07 Phone 1500
---------------------------------------------
Controls used on the VB form are...
-------------------------------------
Data Control named Data1
DBGrid named db1, It's Data source set to Data1
DatePickers named DTPicker1 and DTPicker2
Command Button named CmdExp
Running the code
----------------
DatePicker1 set to 01/01/07 and DatePicker2 set to 21/03/07
Following is the code executed when CmdExp is Clicked...
--------------------------------------------------------------
Private Sub CmdExp_Click()
Dim rs_exp As Recordset
Set rs_exp = db.OpenRecordset("select * from EXPENSES where EDATE >= " & DTPicker1.Value & " and EDATE <=" & DTPicker2.Value & " ")
Set Data1.Recordset = rs_exp
End Sub
The OutPut is
-------------
01/01/07 Electricty 1000
21/01/07 Phone 1500
05/02/07 Electricty 1000
Why does the two records with date 24/01/07 and 23/02/07 is not displayed even though they are between the two date ranges ?
|
|
|
|
|
IF the output is comming like what you have shown then try saving the databas table bafre running the progam and also close the table and then check tha out put. See if it works .
|
|
|
|
|
first, it is much better to use "between" instead of the greater than and equal...
second, maybe because of a time issue
make your two dates boundless to time... format it and parse it as date.
|
|
|
|
|
Maybe this is the wrong place to ask this question but...
I read a lot of posts on other message boards dis-sing Visual Studio 2005 and in particular VB .NET.
I started using VB .NET because I wanted a platform to create exe's and potentially make money out of writing applications.
As an experienced developer in Access and VBA as well as being a SQLServer DBA I wonder if I have made the correct choice with VB .NET.
Now I know that most people posting on this board will probably praise VB .NET however I'd like to hear of others' experiences and how useful is VB .NET including what it's future holds, and examples of strong commercial applications that have been written in VB .NET.
I know I'm asking for a lot...
Guy
You always pass failure on the way to success.
|
|
|
|
|
GuyThiebaut wrote: Now I know that most people posting on this board will probably praise VB .NET
Don't count on it.
There's a large group of people out there who just love to hate VB because of it's rather rocky beginnings and lack of type safety and implicit conversion and ... and ... These are mostly people who come from a C/C++ background.
There's nothing wrong with learning VB.NET and the only problem I see is that your just sticking with VB alone. Don't. Learn as many languages as you can. C# compiles to just about the same MSIL code as VB.NET does. C# has it's roots in a multitude of languages, including VB, so learning C# should be pretty easy.
Also, there's things that VB.NET does that C# can't. The opposite is also true. VB.NET support optional parameters, where C# doesn't. Do some Office Interop in both languages and you'll soon learn to love VB for this ability! C# supports unsafe code and points where VB.NET doesn't. C# is much better for getting directly at the bytes for image manipulation.
Learn as much as you can, VB.NET, C#, Java, SQL, ... It's far more common to write apps in multiple languages than the nay-sayers would care to admit.
|
|
|
|
|
That sounds like good advice based on experience.
I did have a go at C(+) years ago but not being used to OOP it was too early.
On reading what you say I may have a look at C#.
Thanks for that Dave.
You always pass failure on the way to success.
|
|
|
|
|
GuyThiebaut wrote: may have a look at C#
That would be better.
GuyThiebaut wrote: not being used to OOP
OOP is pretty much the game now. I don't remember when I last did good old fashion top-down programming...
|
|
|
|
|
IMO, whichever language you prefer for .NET you should be able to read and understand the other. This is because you will often see useful examples written in only one or the other and you should be able to take advantage of them.
Kevin
|
|
|
|
|
GuyThiebaut wrote: and examples of strong commercial applications that have been written in VB .NET.
As VB.NET code is not secure ( your end users can read it ), a better question would be 'how many web sites use ASP.NET', and 'how many contractors use .NET to write code for specific end users' ?
Note I said '.NET' and not 'C#'. In truth, VB is a nasty little language, but if you understand it, your apps are going to do the same stuff a C# app can do, so there's no real reason to move to C#, if you're comfortable with VB syntax.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I just knew you were going to chime in on this one!
Christian Graus wrote: As VB.NET code is not secure ( your end users can read it ),
Bunch of crap! Of course it's secure, 'cause noone WANTS to read it! Once someone sees it, they say "This can't be a serious app worth my time..."
It's kind of like the great PC/Mac debate. One side thinks the other size sucks. To me, I still get paid by the hour, no matter which language I use.
|
|
|
|
|
In VB6, the underscore is always visible for the hot-key when you use an & in a label. In dotnet, you need to press the alt-key to see the underscore. Any way to override that so the underscore is always visible?
|
|
|
|
|
No. This is a system setting that has nothing to do with your code.
RIght-click the Desktop and pick Properties. Depending on which version of Windows you have, click on the Effects tab (2000) or Appearance tab (WinXP). If XP, click on the Effects button. You're looking for something like "Hide underlined letters for keyboard navigation until I press the Alt key."
No, you can't override it in your app.
|
|
|
|
|
|
Hi,
I'm trying to update the values in a DataGridView. It works ok, and I can see my rows and columns being updated, but when I scroll down the grid, and hit the bottom, it throws an "object not set to an instance of an object" error - and the space occupied by the grid changes to a red cross.
I'm obviously doing something wrong, and have narrowed the problem down to this bit of code:
Dim gridrow As DataRowView<br />
<br />
Dim intItemFoundOnRow As Integer = bindingDataGridView2.Find("File Name", strSearch)<br />
<br />
If intItemFoundOnRow <> -1 Then<br />
<br />
gridrow = bindingDataGridView2.Item(intItemFoundOnRow)<br />
<br />
gridrow.BeginEdit()<br />
<br />
gridrow.Item("Columns in Database") = CountColumnsInTable(strTableName)<br />
<br />
gridrow.EndEdit()<br />
<br />
End If
It isn't anything to do with the CountColumnsInTable function, because I can replace this line with:
gridrow.Item("Columns in Database") = 9999
... and it makes no difference. I threw in .BeginEdit and .EndEdit in an attempt to get it to work, but these lines may as well not be there.
|
|
|
|