|
hi,
Everyone know how to convert this vb6 code
" ListView1.listitem(i + 1).subitem(j + 1).add" to vb.net??
Please help!
charleslau2855
|
|
|
|
|
ListView1.Items(i+1) is how you access the item. I assume it has a SubItems property.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
If you want to add an item to a listview...
If i understand your question right
'Single Entry at the end of the list
<code>Dim _ListViewItem AS ListviewItem = New ListViewItem(New String() {Column1Data, Column2Data, ...ColumnXData}, -1)
_ListView.Items.Add(ListViewItem)</code>
'Multible Entry
<code>Dim _ListViewItems(X) as ListViewItem
Dim _ListViewItem AS ListviewItem</code>
' The loading loop
<code>_ListViewItem = New ListViewItem(New String() {Column1Data, Column2Data, ...ColumnXData}, -1)
_ListViewItems(_ListViewItems.Lengt-1) = ListViewItem </code>
'Loop ends
<code>_ListView.Items.AddRange(ListViewItems</code>)
This is A easy why to add items to a listview...
VB6 =
|
|
|
|
|
I don't think you can add SubItems by index.
However, you can retrieve SubItems by index.
You will probably need to use an array to insert the value at the appropriate index and then rebuild the ListView using your array.
Steve
|
|
|
|
|
Hello.
Can anybody tell me how to create a virtual network interface with the .Net Framework and VB.NET?
Do I have to write a driver in general or is the .net framework able to do this?
thx,
Martin.
|
|
|
|
|
There is a sample driver called NetVMini in the XP DDK.
|
|
|
|
|
You'll have to write a device driver to do this. This is a task not suited to VB.NET or C#. Managed code can be run in Kernel mode, but all the Interop required to do this will slow down the driver considerably. Not to mention you'll be injecting the full weight of the .NET Runtime, about 20 MB worth, into Kernel space. Yuk! Examples and support will be VERY sparse.
Your best language to do something like this is VC++...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'd suggest that you post this to the collaboration forum, and if you have areas you'd like to improve, ask specific questions about them here as well.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I'm getting a file from a listbox that is fileinfo. I'm going to do some reading and writing based on the data in the selected file. I can only find examples of streamreader that use file name as a string. How do I convert the fileinfo to string?
Thanks
silver-gray
|
|
|
|
|
Every .NET class has a tostring method.
What do you mean by FileInfo ? Surely there's a sring there, what's the listbox showing ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You should look into the FileInfo.OpenRead and FileInfo.OpenWrite methods. This will return a FileStream that you can use in the constructor of a StreamReader.
Example
Imports System.IO
Dim fi As FileInfo
'get object from list box
Using fs As FileStream = fi.OpenRead()
'use fi.OpenWrite() for a writeable stream
Using sr As New StreamReader(fs)
'read or write here
End Using
End Using
|
|
|
|
|
Try it out.
It will read a file and will put the contents of file into a string.
Dim reader As StreamReader = File.OpenText("c:\myfile.txt")
Dim line As String = reader.ReadToEnd
Manish
|
|
|
|
|
Try it out.
This code will read a file and will put file's contents into a string
Dim reader As StreamReader = File.OpenText("c:\myfile.txt")
Dim line As String = reader.ReadToEnd
Manish
|
|
|
|
|
I'm writting VBA macro code with array start index as 1 rather 0
Option Base 1
Dim array() As String
If()Then
ReDim array(5)
'fill array with elements
Else
ReDim array(0) 'This statement gives error
End If
I try to use UBound() and LBound() to determine if the array is empty, but can't make it work.
Someone please tell me if there is other way to make it work.
|
|
|
|
|
You can't ReDim an array down to 0 when the Option Base is 1. The lowest you can ReDim down to, obviously, is 1.
I don't know what you mean by "if the array is empty". It appears as though you're trying to ReDim a variable that was an array to no longer be an array. You can't do that. Once a variable is declared, you cannot change it's type. If it's declared as an Integer or Long, it has to stay an Integer or Long. You can't ReDim it to make it an array of Longs. The opposite is also true. Once delcared as an array, it must stay as an array. You can't ReDim it down to a single-valued variable.
I think the function you're looking for is
IsArray(var). This will return True or False depending on if the var is an array or not.<br />
<br />
<br />
<div class="ForumSig"><font color="Blue">Dave Kreskowiak<br />
Microsoft MVP - Visual Basic</font><br />
</div>
|
|
|
|
|
Hi, Dave,
I declared an array, then under certain conditions, this array will be filled with elements, otherwise it will stay empty.
After get through the condition statements, I need to determine if the array is empty.
I tried to use UBound() and LBound(), but I receive compile error on it when the array is not ReDim and filled with elements. what is the best way to determine if the array is empty?
Thanks
Vicky
|
|
|
|
|
"Empty" can be different things. If the variable is not declared an array, or if the variable is declared an array but has no elements, and it can be declared an array and have empty elements.
It depends on the call that's creating the array. You just have to test it to find out.
IsArray will tell you if the variable is declared as an array, but that's it. If that test passes, then you can check its UBound. If it's greater than 0, the array has elements. After that, you check the value of the first element to see if that value is valid.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
try using this
if ubound(array)>=1 then<br />
'array has elements<br />
else<br />
'array is empty<br />
endif
hope this Works...
Nitin...
|
|
|
|
|
I have selected a file from a listbox that I need to read. The selected file is fileinfo, but all the articles I have read are looking for a string for the file w/path.
silver-gray
|
|
|
|
|
hi,
I want to populate the list from db into my treeview and add textbox to another column corresponding to the each lowest child node of the treeview. i am new to vstudio 2005.but experienced in 2003. i tried all datagridview,treeview and listview controls. but can't find out the solution.
eg.
Parent 1
Child0 of Parent 1
child1 of Child0 Textbox1
child2 of Child0 Textbox2
Child00 of Parent 1
child1 of Child00
child2 of Child01 Textbox3
Parent2
.....
what control can i use to achieve this structure?
this is urgent. any help would be greately appreciated.
also i couldnt find any useful articles which to describe databinding in treeview and listview controls. any useful reference?
Thank you all.
|
|
|
|
|
No control exists that will provide this functionality. You'll have to build one yourself. Search the articles for "TreeListView" and you'll find an example of creating your own TreeView control with similar functionality.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello,
I have created a program that monitors different task being done. I have used the StopWatch class, to start and stop different task and get the duration of time it takes to do them. My problem is I want to be able to display them in a datagrid in another form all different tasks with the running times displayed for each task that is currently being done.
The way my program works is that they will select in the datagrid on the main form the task that they want to start, they could do this for many tasks and have many running at the same time. The customer does not want this information displayed on the main form, but displayed in another form. So even though the task are started on the main form, the display form should somehow be able to view the currently running times. These should be displayed in datagrid as there could be many tasks that will be added and deleted from it.
Is it possible to have global variables across both forms, or is there another way to do this.
Many thanks in advance,
Steve
|
|
|
|
|
You should set up delegates between the two forms to pass this sort of info back and forth. There are no globals in .NET, but you can create a class with public static variables and use those, if you must.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Steve,
There is such a thing that I have used in the past. Below is the code for a VB.NET gui application that has two forms, Form1 and Form2. I hope this helps.
In the code behind for Form1, it starts...
Public Class Form1
Inherits System.Windows.Forms.Form
...
Public Shared GameSelected$ 'name of game selected by user or you could declare it Public Shared String GameSelected
...
GameSelected = "lottery"
...
'in my example, when user clicked on a button, the second form appeared
Private Sub GoToSecondForm_Click(ByVal sender As System.Object, ByVal e As System.EventARgs) Handles GoToSecondForm.Click
Dim secondForm as New Form2
secondForm.ShowDialog()
End Sub
...
End Class
'rest of code below is in Form2
Public Class Form2
Inherits System.Windows.Forms.Form
....
DisplayGamesLabel.Text = "Game Selected =" & Form1.GameSelected
End Class
|
|
|
|
|
hi everyone
i m trying to make a stream ripper for shoutcast server.
i m sending a httpwebrequest to the server but i m when trying to get the respone from the server i get protocol violation error
here is the code for sending the web request:
dim ServerPath as string="/"
Dim Prx As New WebProxy("172.31.101.101", 8080)
Prx.BypassProxyOnLocal = True
Prx.Credentials = New NetworkCredential("xyz", "xyz")
if Not Server Is Nothing Then
Request = CType(WebRequest.Create(Server), HttpWebRequest)
Request.Headers.Clear()
Request.Proxy = Prx
Else
MessageBox.Show("Please enter the name of the server you want to connect to", "Server Address Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
End If
Request.Timeout = 500000
Request.Headers.Add("GET", ServerPath & "HTTP/1.1")
Request.Headers.Add("icy-metadata:1")
' Request.UserAgent = "WinampMPEG/5.09"
Try
Response = Request.GetResponse()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error in Connection",MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
End Try
|
|
|
|