-
Apr 13th, 2022, 02:51 PM
#1
Thread Starter
Hyperactive Member
my code not works
im trying to read 2 line but not works
Code:
Dim myOpenFileDialog As New OpenFileDialog()
myOpenFileDialog.Filter = "Android Belgesi (*.and)|*.and|Android Datalı Dosyalar (*.*)|*.*"
If myOpenFileDialog.ShowDialog = DialogResult.OK Then
Dim fileReader As System.IO.StreamReader
fileReader =
My.Computer.FileSystem.OpenTextFileReader(myOpenFileDialog.FileName)
Dim stringReader As String
Dim stringReader2 As String
stringReader = fileReader.ReadLine(0)
stringReader2 = fileReader.ReadLine(1)
Dim ChildForm As New Form1
' Make it a child of this MDI form before showing it.
ChildForm.MdiParent = Me
m_ChildFormNumber += 1
ChildForm.Text = "Android" & m_ChildFormNumber
Dim oldx As Single
oldx = ChildForm.PictureBox1.Left + ChildForm.PictureBox1.Width / 2 'find current center()
ChildForm.PictureBox1.Width = stringReader
ChildForm.PictureBox1.Left = oldx - ChildForm.PictureBox1.Width / 2 'find new left
Dim oldx2 As Single
oldx2 = ChildForm.PictureBox2.Left + ChildForm.PictureBox2.Width / 2 'find current center()
ChildForm.PictureBox2.Width = stringReader2
ChildForm.PictureBox2.Left = oldx2 - ChildForm.PictureBox2.Width / 2 'find new left
ChildForm.Show()
End If
Last edited by gaouser; Apr 13th, 2022 at 03:54 PM.
-
Apr 13th, 2022, 02:57 PM
#2
Re: my code not works
So what's it doing or what's it not doing? You certainly need to be turning Option Strict ON and fixing the errors that will then show up, since you are assigning a string to a property that takes an integer. If the string looks like an integer, then that will work with Option Strict OFF, but it's not reliable. What you should be doing is using either Integer.TryParse, or CInt() to convert the string to an integer explicitly. You'd use TryParse if you aren't certain whether it is a string (if you got the string from the user, for example), and use CInt if you are CERTAIN that the string can be converted to an integer.
In this case, it sounds like you aren't getting what you expect back from ReadLine, but that isn't clear.
My usual boring signature: Nothing
-
Apr 13th, 2022, 03:02 PM
#3
Re: my code not works
Originally Posted by gaouser
im trying to read 2 line but not works
Code:
Dim stringReader As String
Dim stringReader2 As String
stringReader = fileReader.ReadLine(0)
stringReader2 = fileReader.ReadLine(1)
Dim ChildForm As New Form1
' Make it a child of this MDI form before showing it.
ChildForm.MdiParent = Me
m_ChildFormNumber += 1
ChildForm.Text = "Android" & m_ChildFormNumber
Dim oldx As Single
oldx = ChildForm.PictureBox1.Left + ChildForm.PictureBox1.Width / 2 'find current center()
ChildForm.PictureBox1.Width = stringReader
ChildForm.PictureBox1.Left = oldx - ChildForm.PictureBox1.Width / 2 'find new left
Dim oldx2 As Single
oldx2 = ChildForm.PictureBox2.Left + ChildForm.PictureBox2.Width / 2 'find current center()
ChildForm.PictureBox2.Width = stringReader2
ChildForm.PictureBox2.Left = oldx2 - ChildForm.PictureBox2.Width / 2 'find new left
ChildForm.Show()
End If
I can't believe my eyes! Code!
Gaousy posted code!!!
-
Apr 13th, 2022, 03:55 PM
#4
Thread Starter
Hyperactive Member
-
Apr 13th, 2022, 03:56 PM
#5
Thread Starter
Hyperactive Member
Re: my code not works
in extra stop calling me as Gaousy my name is shourtcut to (Google android oyunları (Fan Made) VB forum User)
-
Apr 13th, 2022, 05:06 PM
#6
Thread Starter
Hyperactive Member
Re: my code not works
yes moderator not working im making androidify remake on vb.net (im gonna stop vb6 version)
-
Apr 13th, 2022, 06:20 PM
#7
Re: my code not works
When you step through the code with the debugger, at what point does it not do what you expect it to do?
For instance
Code:
stringReader = fileReader.ReadLine(0)
stringReader2 = fileReader.ReadLine(1)
When you step through those lines were the variables set to the strings you expected from the file?
And if they worked, then continue stepping until what you expect to happen didn't happen.
You can get better help if you identify the line where the code doesn't do what you expect it to do and you point it out.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Apr 14th, 2022, 03:19 AM
#8
Thread Starter
Hyperactive Member
Re: my code not works
2st string reader gives me 0 not 2st line (i changed 1 to 2)
-
Apr 14th, 2022, 03:21 AM
#9
Thread Starter
Hyperactive Member
Re: my code not works
inside of my file is
192
200
these are width for head and body (i have plan.im gonna create a function) and merge these
-
Apr 14th, 2022, 03:26 AM
#10
Re: my code not works
Unless I am missing something ReadLine doesn't take an integer, it just returns the next line https://docs.microsoft.com/en-us/dot...eader-readline so I am not even sure how that code compiles.
-
Apr 14th, 2022, 03:32 AM
#11
Re: my code not works
This is a perfect example of why you need to pay attention to Intellisense at least and, better yet, read the documentation when using types and members that you're not familiar with. This code:
vb.net Code:
stringReader = fileReader.ReadLine(0)
stringReader2 = fileReader.ReadLine(1)
is very bad. If you actually intended what it's actually doing then it's very poorly written but I'm certain that that's not what you intended. That code is actually doing this:
vb.net Code:
stringReader = fileReader.ReadLine().Chars(0)
stringReader2 = fileReader.ReadLine().Chars(1)
You appear to be trying to tell the StreamReader which line to read, but there is no such ReadLine method, which you would know if you had paid attention to Intellisense or read the documentation. ReadLine has no parameters and simply reads the next line. Because you tried to pass an argument, the compiler assumed that you were actually calling ReadLine without parentheses and then indexing the String that it returns. That means that the first line of code will read the first line of the file and return the first character from that line and assign it to the variable, then the second line of code will read the second line of the file and return the second character from it and assign that to the variable. Just get rid of the numbers and it will work as I suspect you want it to.
Last edited by jmcilhinney; Apr 14th, 2022 at 03:51 AM.
-
Apr 14th, 2022, 04:42 AM
#12
Thread Starter
Hyperactive Member
-
Apr 14th, 2022, 04:44 AM
#13
Thread Starter
Hyperactive Member
Re: my code not works
1st one gived me 1 2st one gived me 2 but its not on the file i write
-
Apr 14th, 2022, 04:45 AM
#14
Re: my code not works
Show the updated code you used and show the content of the file.
-
Apr 14th, 2022, 05:02 AM
#15
Re: my code not works
Originally Posted by gaouser
(im gonna stop vb6 version)
No, already? I needed it next month...
https://github.com/yereverluvinunclebert
Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.
By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.
-
Apr 14th, 2022, 05:25 AM
#16
Re: my code not works
He showed the content of the file in post #9.
It seems he didn't understand jmc's post #11, and is still using an index parameter so is now reading the first character of each line, rather than the whole line.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Apr 14th, 2022, 06:00 AM
#17
Re: my code not works
Yes sorry, I missed that.
Then it's clear he didn't changed his code to just do a ReadLine without a parameter
-
Apr 14th, 2022, 07:56 AM
#18
Re: my code not works
y'all are trying too hard ... let me see if I can translate it into gaousereesee...
no work...
Code:
stringReader = fileReader.ReadLine(0)
stringReader2 = fileReader.ReadLine(1)
yes work...
Code:
stringReader = fileReader.ReadLine()
stringReader2 = fileReader.ReadLine()
-tg
-
Apr 14th, 2022, 08:48 AM
#19
Re: my code not works
Originally Posted by techgnome
y'all are trying too hard ... let me see if I can translate it into gaousereesee...
no work...
Code:
stringReader = fileReader.ReadLine(0)
stringReader2 = fileReader.ReadLine(1)
yes work...
Code:
stringReader = fileReader.ReadLine()
stringReader2 = fileReader.ReadLine()
-tg
Your Gaouserish is pretty good!
-
Apr 14th, 2022, 09:04 AM
#20
Re: my code not works
Gaouser, why does your PictureBoxes have to get their size and location from a file? Wouldn't it be easier if you just assigned everything under the Picturebox properties, and then code it so your PictureBoxes dynamically change it's size and location according to certain conditions?
What exactly are you using the PictureBoxes for?
Last edited by Peter Porter; Apr 14th, 2022 at 09:28 AM.
-
Apr 14th, 2022, 02:51 PM
#21
Thread Starter
Hyperactive Member
Re: my code not works
these are creating a android logo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|