473,320 Members | 1,867 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,320 software developers and data experts.

Convert 6.0 to net

7
I have the following code written for net but need to run it in 6.0

Dim FileNum as Integer = FreeFile () and it doesn't like the =

trouble opening a text file code is:

FileOpen(FilNum, "Hits.txt", OpenMode. Input)

also trouble with:

song = LineInput(FileNum)
Oct 30 '07 #1
5 1504
I have the following code written for net but need to run it in 6.0

Dim FileNum as Integer
FileNum = FreeFile ()

trouble opening a text file code is:

FileOpen(FilNum, "Hits.txt", OpenMode. Input)

also trouble with:

song = LineInput(FileNum)
In VB6 you cannot give a default value in the declaration itself. See the changes in BOLD above
Oct 30 '07 #2
woo
7
In VB6 you cannot give a default value in the declaration itself. See the changes in BOLD above
thanks for your help, still having trouble so sending the whole code for the project. this is being written by one of my students - and above my ability.

code as follows:
Expand|Select|Wrap|Line Numbers
  1. Private Sub btnclear_Click()
  2.  
  3.   txtSearch.Text = " "
  4.   lblsongdisplay.Text = " "
  5.   txtSearch.Focus()
  6.  
  7. End Sub
  8.  
  9. Private Sub btnExit_Click()
  10.  
  11.   End
  12.  
  13. End Sub
  14.  
  15. Private Sub btnShowsong_Click()
  16.   If lstNames.SelectedIndex > -1 Then
  17.     'select corresponding item in song list
  18.     lstSongs.SelectedIndex = lstNames.SelectedIndex
  19.     lblSong.Text = lstSongs.Text
  20.     'focus back to search text box
  21.   Else
  22.     MessageBox.Show("No artist selected. " , " Hit Songs " ,_
  23.     MessageBoxButtons.OK, MesssageBoxIcon.Exclamation)
  24.   End If
  25. End Sub
  26.  
  27. Private Sub lblsongdisplay_Click()
  28.  
  29. End Sub
  30.  
  31. Private Sub ListBox1_Click()
  32.  
  33. End Sub
  34.  
  35. Private Sub txtNameofsong_Change()
  36.  
  37. End Sub
  38.  
  39. Private Sub lstNames_Click()
  40.   Dim Artist, song As String
  41.   Dim FileNum As Integer = FreeFile  ()
  42.   ' find available file number
  43.   FileOpen(FileNum, " Hits.txt " , OpenMode. Input)
  44.  
  45.   'open text file
  46.   Do Until EOF(FileNum)
  47.     'read until end of file
  48.     Artist = LineInput(FileNum)
  49.     'read artist name
  50.     lstNames.Items.Add (Artist)
  51.     'add to list
  52.     Song = LineInput(FileNum)
  53.  
  54.     'read song name
  55.     lstSongs.Items.Add (song)
  56.     'add to list
  57.   Loop
  58.   FileClose (FileNum)
  59.  
  60. End Sub
  61.  
  62. Private Sub lstSongs_Click()
  63.   Dim Artist, song As String
  64.   Dim FileNum As Integer
  65.   FileNum = FreeFile()
  66.   ' find available file number
  67.   FileOpen = FilNum "Hits.txt",OpenMode.Input)
  68.   'open text file
  69.   Do Until EOF(FileNum)
  70.   'read until end of file
  71.     Artist = LineInput(FileNum)
  72.     'read artist name
  73.     lstNames.Items.Add (Artist)
  74.     'add to list
  75.     Song=LineInput(FileNum)
  76.     'read song name
  77.     lstSongs.Items.Add (song)
  78.     'add to list
  79.   Loop
  80.   FileClose (FileNum)
  81. End Sub
  82.  
  83. Private Sub txtSearch_Change()
  84.   Dim MatchFound As Boolean = False
  85.   Dim Last As Integer, I As Integer = 0
  86.   If txtSearch.Text > "" Then
  87.   ' must have something to find
  88.     lblSong.Text = " "
  89.     Last = lstNames.Items.Count - 1
  90.     Do
  91.       'check for a match in this list item
  92.       If InStr(lstNames.Items.Item(I), txtSearch.Text, CompareMethod.Text) > 0 Then
  93.         MatchFound = True
  94.         1   stNames.SelectedIndex = -1 'highlight the match
  95.       End If
  96.   ' Something is wrong with the code from here onward...
  97.   Else
  98.       lstNames.SelectedIndex = -1 nothing selected
  99.    End If
  100.  
  101. End Sub
Oct 30 '07 #3
Killer42
8,435 Expert 8TB
I added a CODE=vb tag and tried to tidy up the indenting, but around line 94 the code goes all wrong so I wasn't able to finish.

Is this about converting VB6 code to VB.Net, or the other way around, or what?
Oct 31 '07 #4
QVeen72
1,445 Expert 1GB
Hi,

Syntax to open file in VB6 is :
Declare FileNum as Long..

Expand|Select|Wrap|Line Numbers
  1. FileNum = FreeFile()
  2. Open "C:\Hits.txt" For Input As FileNum
  3.  
  4. Do Until EOF(FileNum)
  5.    Input FileNum, Artist
  6.     lstNames.Items.Add (Artist)
  7.    ' Similarly write for Others also..
  8. Loop
  9.  
Regards
Veena
Oct 31 '07 #5
Killer42
8,435 Expert 8TB
Open is the simpler method, of course. Probably the preferred method is to use FileSystemObject.
Oct 31 '07 #6

Sign in to post your reply or Sign up for a free account.

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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.