|
YOu can look at my image processing articles for how to read the pixels of an image directly. VB.NET cannot do this, you'd have to do it in C#. The (slow) alternative is to use the GetPixel method. Then you can either work out the shapes that are the same color, or count colors, depending on how complex the shapes are.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I've got what should be an easy question, but I can't find the correct combination in VB.NET.
I have a drop down list of numbers in a combo box. When I leave the form, I want to know which number was chosen.
NumSamp.SelectedIndex()
tells me which index I've chosen, but I can't get the integer or text value of the entry.
NumSamp.SelectedText() or NumSamp.SelectedValue() both come back as nothing.
There must be an easy way to get the value of the chosen entry, but I can't seem to find it.
Thanks,
Ilan
|
|
|
|
|
why can't you use
Request.form("id of combobox").value
it returns index of number selected by user when he leaves the form
use
document.all("idofcombobox").value in javascript for same value without post back form
|
|
|
|
|
Visual Basic doesn't understand "Request" and since I've never used it, neither do I.
While I'm still in the form, I have the combo box. It is called NumSamp.
It seems to me that I ought to be able to query NumSamp in some easy way to find out which value in a list of values was chosen.
In fact, NumSamp.SelectedIndex() gives me the correct offset in the list of values. I'm just missing the next step: given the index, what is the value of the entry?
Thanks,
Ilan
|
|
|
|
|
NumSamp.SelectedIndex.value
will solve your problem
|
|
|
|
|
Thanks for your kind answer.
|
|
|
|
|
Use NumSamp.SelectedItem . If you're coding with Option Strict On use the .ToString() method as well.
Sample
Private Sub Button1_Click(...) Handles Button1.Click
'pass value of selected item to Form2
Dim frm2 As New Form2
frm2.Text = Me.ComboBox1.SelectedItem.ToString
frm2.Show()
End Sub
|
|
|
|
|
Thanks,
It was under my nose all the time and somehow I missed it.
As I expected, it is really easy.
|
|
|
|
|
Let say i have the data below in a textfile call testing.txt
No,Title
1,Information
2,Error message
3,Question
Now, how can i specify,get and display the second line data?
I would appreciate so much for help!!
|
|
|
|
|
If it's the second line, you can read a line at a time and use the second one. Or you can use a regex to parse the data.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks for help, but can i have sample coding?
|
|
|
|
|
System.IO.File.ReadXXX is the group of methods that are the easiest way to read a file into a string or group of strings.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Sorry for the troublesome! This is some of my code which i only manage to get title as return. May i have some advice on it?
Private Function ReadTextFile(ByVal sFileName As String) As String
Dim s As String = String.Empty
Try
Dim oFile As FileStream = New FileStream(sFileName, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim oReader As StreamReader = New StreamReader(oFile)
s = oReader.ReadLine()
oReader.Close()
oFile.Close()
ReadTextFile = s
Catch
ReadTextFile = "Unable to open file."
End Try
End Function
|
|
|
|
|
Your problem is that you're only reading the first line of the file.
The ReadLine call needs to be a recurrent call, based on the return value of the method.
e.g. (from MSDN)
<br />
Dim input As String<br />
input = sr.ReadLine()<br />
While Not input Is Nothing<br />
'Do something with the input<br />
<br />
'Read the next line of input<br />
input = sr.ReadLine()<br />
End While<br />
This will continue to read the file until there is no further input returned by the ReadLine() call. Then you'll have to compare the returned input string to whatever you want to catch, either using a regex or a string constant (in the case of a marker string or something that won't change) to get the particular peice of info you're after. I would add do it something like this...
<br />
Dim input As String<br />
input = sr.ReadLine()<br />
While Not input Is Nothing<br />
<br />
If (input.CompareTo(stringConstant) = 0)<br />
'do whatever with the data<br />
input = Nothing<br />
Else<br />
input = sr.ReadLine() <br />
End If<br />
End While<br />
|
|
|
|
|
Thank u, it really help a lot!
|
|
|
|
|
Hi all,
I have created application for uploading huge chunk file (min 1gb) to server(CONTENT MGMT SERVER).
File Size TIME
1.4 GB 22 Minutes
3.17 GB 32 Minutes
I am reading 10MB chunks for each partial write and utilizing maximum of 25 threads running at any point of time during execution. Can anyone help me to improve performance application.
I would appreciate, If anyone give me suggestion to improve performance of application.
Thanks,
Vijay Kumar
Email#jaydotnet@gmail.com
vijay
|
|
|
|
|
jaydotnet wrote: Can anyone help me to improve performance application.
Upgrade to an OC48 line? Warning! Can be cut by any idiot with a backhoe.
jaydotnet wrote: 10MB chunks for each partial write and utilizing maximum of 25 threads
25 threads? For what?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave,
I appreciate your reply.
I am using window application for uploading this huge data to content management server. when i try to transfer 1 huge chunk data (more than 1 gb) it take more than 1 hr to transfer. content mgmt server reads data byt 16kb and buffers in internal memory then writes to server. content management server group suggested us to read file into multiple slice and upload file using multi-threading(max 25 at any time). After doing this we had some performance improvement but no upto expectation.
if you need i can post my code.
thanks
Vijay
|
|
|
|
|
I see. It would appear that this is the best performance you're going to get. Not because of your code, but because of performance issues on the server side. If you're really good with a protocol analyzer, you can watch the traffic go by and look at the times it's taking for acknowledgement traffic to come back from the server.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I need to be able to search a DataTable for a non-primary key field. I'd assume the best way is just to populate a dataset and fill the table. But how do I search the table for non-primary key values?
Nathan Lindley
.NET Aficionado
|
|
|
|
|
Something along the lines of
<br />
for each datarow in datatable<br />
if datarow.coumn(i) = searchvalue then<br />
return what you want<br />
end if<br />
next<br />
Mike Lasseter
|
|
|
|
|
I had played around with iterating the DataTable for the row, but was unsuccessful. I guess i'll play around with it a little more. Thanks.
Nathan Lindley
.NET Aficionado
|
|
|
|
|
Dim dr() as DataRow
dr = datatable.Select("FieldName = 'something'")
dr will be an array of rows from the datatable that match the query.
|
|
|
|
|
You can't assign a dataRow to an Array of datarows...i think the error says something like '1 dimensional array System.Data.DataRow cannot be converted to System.Data.DataRow' ... thanks for the response though.
Nathan Lindley
.NET Aficionado
|
|
|
|
|
It works. I've used it many times. You must declare the DataRow variable as an array. **use the parentheses after the name of the variable**
Dim dr() As DataRow
The select function of the DataTable class will return an array of data row objects.
I am using .NET 2005
|
|
|
|