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)
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
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: - Private Sub btnclear_Click()
-
-
txtSearch.Text = " "
-
lblsongdisplay.Text = " "
-
txtSearch.Focus()
-
-
End Sub
-
-
Private Sub btnExit_Click()
-
-
End
-
-
End Sub
-
-
Private Sub btnShowsong_Click()
-
If lstNames.SelectedIndex > -1 Then
-
'select corresponding item in song list
-
lstSongs.SelectedIndex = lstNames.SelectedIndex
-
lblSong.Text = lstSongs.Text
-
'focus back to search text box
-
Else
-
MessageBox.Show("No artist selected. " , " Hit Songs " ,_
-
MessageBoxButtons.OK, MesssageBoxIcon.Exclamation)
-
End If
-
End Sub
-
-
Private Sub lblsongdisplay_Click()
-
-
End Sub
-
-
Private Sub ListBox1_Click()
-
-
End Sub
-
-
Private Sub txtNameofsong_Change()
-
-
End Sub
-
-
Private Sub lstNames_Click()
-
Dim Artist, song As String
-
Dim FileNum As Integer = FreeFile ()
-
' find available file number
-
FileOpen(FileNum, " Hits.txt " , OpenMode. Input)
-
-
'open text file
-
Do Until EOF(FileNum)
-
'read until end of file
-
Artist = LineInput(FileNum)
-
'read artist name
-
lstNames.Items.Add (Artist)
-
'add to list
-
Song = LineInput(FileNum)
-
-
'read song name
-
lstSongs.Items.Add (song)
-
'add to list
-
Loop
-
FileClose (FileNum)
-
-
End Sub
-
-
Private Sub lstSongs_Click()
-
Dim Artist, song As String
-
Dim FileNum As Integer
-
FileNum = FreeFile()
-
' find available file number
-
FileOpen = FilNum "Hits.txt",OpenMode.Input)
-
'open text file
-
Do Until EOF(FileNum)
-
'read until end of file
-
Artist = LineInput(FileNum)
-
'read artist name
-
lstNames.Items.Add (Artist)
-
'add to list
-
Song=LineInput(FileNum)
-
'read song name
-
lstSongs.Items.Add (song)
-
'add to list
-
Loop
-
FileClose (FileNum)
-
End Sub
-
-
Private Sub txtSearch_Change()
-
Dim MatchFound As Boolean = False
-
Dim Last As Integer, I As Integer = 0
-
If txtSearch.Text > "" Then
-
' must have something to find
-
lblSong.Text = " "
-
Last = lstNames.Items.Count - 1
-
Do
-
'check for a match in this list item
-
If InStr(lstNames.Items.Item(I), txtSearch.Text, CompareMethod.Text) > 0 Then
-
MatchFound = True
-
1 stNames.SelectedIndex = -1 'highlight the match
-
End If
-
' Something is wrong with the code from here onward...
-
Else
-
lstNames.SelectedIndex = -1 nothing selected
-
End If
-
-
End Sub
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?
Hi,
Syntax to open file in VB6 is :
Declare FileNum as Long.. -
FileNum = FreeFile()
-
Open "C:\Hits.txt" For Input As FileNum
-
-
Do Until EOF(FileNum)
-
Input FileNum, Artist
-
lstNames.Items.Add (Artist)
-
' Similarly write for Others also..
-
Loop
-
Regards
Veena
Open is the simpler method, of course. Probably the preferred method is to use FileSystemObject.
Sign in to post your reply or Sign up for a free account.
Similar topics
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....
|
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...
|
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...
|
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...
|
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...
|
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
|
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...
|
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...
|
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.
...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
|
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...
|
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...
| |