Getting started, Visual Basic beginner

B

brock

Hi, I do apologize as I'm sure this kind of post is frowned on... But
I'm stumped and just need a kick in the right direction...

I'm using Visual Basic 2008 Express Edition.

My goal: Take input from a TextBox, check it for a certain string, and
output the remainder of the line to a file.

I've just about everything working, except the part that gets the
remainder of the line. That is the part that has got me stumped.
This is what I have (and I welcome and criticism/advice)

Dim sOutput As String
Dim iPos As Integer
Dim sData As String
Dim sChar As String
Dim iLooking As Integer
Dim sInput As String
sInput = RegistrationInput.Text
iPos = InStr(sInput, "1a_firstname: ")
If iPos = 0 Then
sOutput = "1a_firstname: Not found!"
Else
iLooking = iPos + 14
sChar = GetChar(sInput, iLooking)
While sChar IsNot vbCrLf
iLooking += 1
sData += sChar
sChar = GetChar(sInput, iLooking)
End While
sOutput = sData
End If
My.Computer.FileSystem.WriteAllText("C:\My Computer
\conference_reg.txt", sOutput, False)
 
C

Cor Ligthert[MVP]

brock,

Be aware that the article is written by a beginner.
It starts already with something that is an own opinion about VB for Net,
not something that is as needed.

Cor
 
C

Cor Ligthert[MVP]

Brock

Don't declare all your local datanames in the top of a method, that is from
before 1990
Don't give all your datanames a prefix for the used value types
Don't give your names which can mixed up by a keyword, by instance ichar
would mean Interface for char. (as I have seen used by almost everybody)
There is no need to tell what Type somethng is inside a method as VB 2008
interfer that by the signature of the result.
Dim a = "MyString"
is perfectly well.

Probably others see other things,

Cor
 
M

Miro

Cor I am not exactly sure what you mean by
"It starts alread ywith something that is an own option about vb for ne, sot
something that is needed"

Does the example given thru steps 1 to 3, not give the desired output ? - or
is this the wrong way about string manipulation for what brock is looking
for?

I thought I found him a good link that gets him exactly what he is looking
for. If im searching wrong on google... I would like to know too :)

Thanks,

Miro
 
C

Cor Ligthert[MVP]

Miro,

It seems for some people that the Net framework is not including Visual
Basic.

However VisualBasic for Net is a full part of the Net framework and
therefore all language elements are valid.

Therefore why start a page with showing alternatives for full Net framework
Visual Basic methods?

It shows for me that the writter of the page does not understand it.

Cor
 
B

Bill McCarthy

FWIW, I think the article is on the right track. The problems with using VB
language functions is they are general 1 based instead of zero based, and it
gets confusing when you intermix the two. The simplest is to use 0 based.
So, for example, I would use the .IndexOf method on string, and not use VB's
InStr.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top