473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Convert from VB 6

Can someone please convert the following codes into VB.NET?
Thanks Bill

-------------

' In general Declarations
Dim tvn As Node

Private Sub Command1_Click()
Me.MousePointer = vbHourglass

TreeView1.Nodes.Clear

' Pathname to create folder/file list from
p$ = Dir1.Path
If Right$(p$, 1) <> "\" Then p$ = p$ + "\"

Set tvn = TreeView1.Nodes.Add(, tvwParent, p$, p$)

RecurseFiles2 p$

Me.MousePointer = vbDefault
End Sub

Sub RecurseFiles2(ByVal fPath As String)
Dim File_Name As String
Dim File_Read As Integer ' Number of Files Read
Dim strTempPath As String
Dim i As Integer

If Right$(fPath, 1) <> "\" Then fPath = fPath & "\"

' to do a pattern match do, or something.
' folders won`t be included in the list (not my fault)
' File_Name = Dir$(fPath+"\*.exe", vbDirectory)

File_Name = Dir$(fPath, vbDirectory)
File_Read = 1

Do While File_Name <> ""
If File_Name <> "." And File_Name <> ".." Then
strTempPath = fPath & File_Name

If GetAttr(strTempPath) And vbDirectory Then
Set tvn = TreeView1.Nodes.Add(fPath, tvwChild, strTempPath +
"\", File_Name)
RecurseFiles2 strTempPath ' if a folder, then call this
routine to scan that folder (recursion)

File_Name = Dir$(fPath, vbDirectory)
For i = 2 To File_Read
File_Name = Dir$
Next
Else
Set tvn = TreeView1.Nodes.Add(fPath, tvwChild, strTempPath,
File_Name)
End If
End If

File_Name = Dir$
File_Read = File_Read + 1
Loop
End Sub
Nov 21 '05 #1
2 1991
You might start by looking at the FileDialog class in .NET. It encapsulates
just about everything you're trying to do here. If you want to go it this
way though, start by getting rid of all those God-awful $'s on your string
variables. "Node" is now a TreeNode. .MousePointer is now .Cursor with its
own set of enumerations. Not sure where your Dir1.Path is coming from
here...

I just found several other items in MSDN Online Help for VS.NET. Why not
type some of the items that are giving you errors below into the Search?
Almost all of them return the relevant help screens.

"Bill nguyen" <bi*****************@jaco.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Can someone please convert the following codes into VB.NET?
Thanks Bill

-------------

' In general Declarations
Dim tvn As Node

Private Sub Command1_Click()
Me.MousePointer = vbHourglass

TreeView1.Nodes.Clear

' Pathname to create folder/file list from
p$ = Dir1.Path
If Right$(p$, 1) <> "\" Then p$ = p$ + "\"

Set tvn = TreeView1.Nodes.Add(, tvwParent, p$, p$)

RecurseFiles2 p$

Me.MousePointer = vbDefault
End Sub

Sub RecurseFiles2(ByVal fPath As String)
Dim File_Name As String
Dim File_Read As Integer ' Number of Files Read
Dim strTempPath As String
Dim i As Integer

If Right$(fPath, 1) <> "\" Then fPath = fPath & "\"

' to do a pattern match do, or something.
' folders won`t be included in the list (not my fault)
' File_Name = Dir$(fPath+"\*.exe", vbDirectory)

File_Name = Dir$(fPath, vbDirectory)
File_Read = 1

Do While File_Name <> ""
If File_Name <> "." And File_Name <> ".." Then
strTempPath = fPath & File_Name

If GetAttr(strTempPath) And vbDirectory Then
Set tvn = TreeView1.Nodes.Add(fPath, tvwChild, strTempPath +
"\", File_Name)
RecurseFiles2 strTempPath ' if a folder, then call this
routine to scan that folder (recursion)

File_Name = Dir$(fPath, vbDirectory)
For i = 2 To File_Read
File_Name = Dir$
Next
Else
Set tvn = TreeView1.Nodes.Add(fPath, tvwChild, strTempPath,
File_Name)
End If
End If

File_Name = Dir$
File_Read = File_Read + 1
Loop
End Sub

Nov 21 '05 #2
Hi,

Take a look at the vb power packs folder viewer control.
http://msdn.microsoft.com/library/de...bpowerpack.asp

Ken
-------------------
"Bill nguyen" <bi*****************@jaco.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Can someone please convert the following codes into VB.NET?
Thanks Bill

-------------

' In general Declarations
Dim tvn As Node

Private Sub Command1_Click()
Me.MousePointer = vbHourglass

TreeView1.Nodes.Clear

' Pathname to create folder/file list from
p$ = Dir1.Path
If Right$(p$, 1) <> "\" Then p$ = p$ + "\"

Set tvn = TreeView1.Nodes.Add(, tvwParent, p$, p$)

RecurseFiles2 p$

Me.MousePointer = vbDefault
End Sub

Sub RecurseFiles2(ByVal fPath As String)
Dim File_Name As String
Dim File_Read As Integer ' Number of Files Read
Dim strTempPath As String
Dim i As Integer

If Right$(fPath, 1) <> "\" Then fPath = fPath & "\"

' to do a pattern match do, or something.
' folders won`t be included in the list (not my fault)
' File_Name = Dir$(fPath+"\*.exe", vbDirectory)

File_Name = Dir$(fPath, vbDirectory)
File_Read = 1

Do While File_Name <> ""
If File_Name <> "." And File_Name <> ".." Then
strTempPath = fPath & File_Name

If GetAttr(strTempPath) And vbDirectory Then
Set tvn = TreeView1.Nodes.Add(fPath, tvwChild, strTempPath +
"\", File_Name)
RecurseFiles2 strTempPath ' if a folder, then call this
routine to scan that folder (recursion)

File_Name = Dir$(fPath, vbDirectory)
For i = 2 To File_Read
File_Name = Dir$
Next
Else
Set tvn = TreeView1.Nodes.Add(fPath, tvwChild, strTempPath,
File_Name)
End If
End If

File_Name = Dir$
File_Read = File_Read + 1
Loop
End Sub

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
1
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
7
by: whatluo | last post by:
Hi, all I'm now working on a program which will convert dec number to hex and oct and bin respectively, I've checked the clc but with no luck, so can anybody give me a hit how to make this done...
3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
4
by: Edwin Knoppert | last post by:
In my code i use the text from a textbox and convert it to a double value. I was using Convert.ToDouble() but i'm used to convert comma to dot. This way i can assure the text is correct. However...
1
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in...
6
by: Ken Fine | last post by:
This is a basic question. What is the difference between casting and using the Convert.ToXXX methods, from the standpoint of the compiler, in terms of performance, and in other ways? e.g. ...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.