Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / February 2004



Tip: Looking for answers? Try searching our database.

Checking for letters in a string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
WStoreyII - 29 Feb 2004 07:09 GMT
when using the instr()function i can check for a space by gong " " but how
do i check for a number or letter not a particular number but just go to the
first number or letter depending on what i need?

WStoreyII
Randy Day - 29 Feb 2004 07:29 GMT
> when using the instr()function i can check for a space by gong " " but how
> do i check for a number or letter not a particular number but just go to the
> first number or letter depending on what i need?

The Mid() function, and a DO WHILE loop...

> WStoreyII
WStoreyII - 29 Feb 2004 07:35 GMT
> > when using the instr()function i can check for a space by gong " " but how
> > do i check for a number or letter not a particular number but just go to the
[quoted text clipped - 3 lines]
>
> > WStoreyII
but what parameters do i use to tell it that i need to check for letters? is
there a character like !#$ ect that tells it to look for letters ??????
J French - 29 Feb 2004 07:39 GMT
>when using the instr()function i can check for a space by gong " " but how
>do i check for a number or letter not a particular number but just go to the
>first number or letter depending on what i need?

I'm afraid you need to check each character
- extracting it with Mid$()

You could use the Like Operator

Private Sub Command1_Click()
   Dim S$, L9&, FoundPos&
         
   S$ = " ; ,ABC  "
   For L9 = 1 To Len(S$)
       If Mid$(S$, L9, 1) Like "[A-Za-z0-9]" Then
          FoundPos = L9
          Exit For
       End If
   Next
   Me.Print FoundPos
End Sub
WStoreyII - 29 Feb 2004 07:45 GMT
> >when using the instr()function i can check for a space by gong " " but how
> >do i check for a number or letter not a particular number but just go to the
[quoted text clipped - 19 lines]
>
> i am sure this is going to sound like a stupid question but as i said i am
a new bie what are all the $ & signs ????
J French - 29 Feb 2004 08:16 GMT
>> i am sure this is going to sound like a stupid question but as i said i am
>a new bie what are all the $ & signs ????

 '$' means that the variable is a String
 '&' means that the variable is a Long Integer

Dim A$
is exactly the same as
Dim A As String

However, from your next post it looks horribly as if you are using
VB.NET - most people here use VB5 or VB6

If you are using VB.NET then :-

For the microsoft news server, try these newsgroups...

microsoft.public.dotnet.general
microsoft.public.dotnet.languages.vb
microsoft.public.vsnet.general
WStoreyII - 29 Feb 2004 08:25 GMT
> >> i am sure this is going to sound like a stupid question but as i said i am
> >a new bie what are all the $ & signs ????
[quoted text clipped - 16 lines]
> microsoft.public.dotnet.languages.vb
> microsoft.public.vsnet.general

yes i am using vb.net you say this as if this is a bad thing?  I have to use
this group though because the ones you listed never answer my post this is
the only post with people who actually help me.
J French - 29 Feb 2004 08:49 GMT
<snip>

>yes i am using vb.net you say this as if this is a bad thing?  I have to use
>this group though because the ones you listed never answer my post this is
>the only post with people who actually help me.

VB.NET is /not/ VB 'Classic'
- it is pretty much a different language

Most people here are rather annoyed that MS are dropping support for
VB6 and are trying to coerce us onto the .NET platform

The reason why people are probably not answering your posts on the MS
dotnet NGs is probably because they are too simple

You need to get used to finding out the simple stuff for yourself

For example the answer to your 'Remove' question is at:

http://tinyurl.com/3bw3h

The trick to learning how to program is 'learning how to learn'
- examining the Help system
- using the MS website
- reading the manuals
- locating helpful web sites
- testing things out
WStoreyII - 29 Feb 2004 08:59 GMT
> <snip>
>
[quoted text clipped - 23 lines]
> - locating helpful web sites
> - testing things out

I appreciate all of your help but please try to remeber back to when you did
not know what you were doing and how hard the msdn was to understand at
least for me.  What is simple to you is not simple to everyone and please do
not assume that i have not read the help.  I have read every article on the
msdn under remove and i at least have not been able to make english out of
it as i said i am a newbie.

WStoreyII
J French - 29 Feb 2004 10:53 GMT
<snip>

>I appreciate all of your help but please try to remeber back to when you did
>not know what you were doing and how hard the msdn was to understand at
>least for me.  What is simple to you is not simple to everyone and please do
>not assume that i have not read the help.  I have read every article on the
>msdn under remove and i at least have not been able to make english out of
>it as i said i am a newbie.

The trick is to open up a new App and play with the command until one
can work out how to use it.

Not using VB.NET I looked it up on MSDN
- which I admit took a bit of effort
- and the syntax looked pretty simple

The danger of getting assistance from VB5/VB6 NGs is that people will
tell you the VB5/6 way of doing things

For example :   MyString.Remove( FromIndex, NoOfChars )
simply does not exist in VB5/6

We would use:
    MyString = Left$( MyString, FromPos-1 )
                     + Mid$( MyString, FromPos + NoOfChars )

We would not know that FromIndex is zero based ( which is IMO a very
silly idea ) and is intended to be used with
MyString.IndexOf( StartIndex, SmallString )
and /not/ with InStr() which is One based

You are simply in the wrong NG, and it will cause you confusion

My guess is that you have been given a homework assignment, and
'teacher' is being a little tricky - trying to catch you out on the
difference between InStr and IndexOf
- it is the nasty sort of one upmanship games that teachers play

I strongly suggest that you settle down with a program consisting of
little more than a command button, and play with the rudimentary
string commands until you understand them
- believe it or not, that is how even very experienced programmers
work

Also, when I said you nead 'to learn how to learn' I was not
criticizing you - I really meant it as sound advice
- most higher education is 'learning how to teach oneself'

I suspect the reason why the dotnet NGs are not helpful to you is
because they are wrestling with much more complicated problems

However, there must be some NGs out there for VB.NET beginners to help
each other.
Thornmastr@NOSPAM.earthlink.net - 29 Feb 2004 13:35 GMT
> The reason why people are probably not answering your posts on the MS
> dotnet NGs is probably because they are too simple

While his questions might be "too simple" to the brilliant "guru's" on the
.net groups, that is certainly not a justification for their totally
ignoring his question.

At the least, they could have pointed him toward an article or even a
beginning manual for some help.

Signature

Robert Berman
Vulcan Software Services
Thornmastr@NOSPAM.earthlink.net

Don@home.com - 29 Feb 2004 13:41 GMT
>> The reason why people are probably not answering your posts on the MS
>> dotnet NGs is probably because they are too simple
[quoted text clipped - 5 lines]
>At the least, they could have pointed him toward an article or even a
>beginning manual for some help.

If you're going to be a DoTnEt'er you have to think like one..
Just word you question(s) to make them sound more difficult than they really
are...

Have a good day...

Don
J French - 29 Feb 2004 14:11 GMT
>> The reason why people are probably not answering your posts on the MS
>> dotnet NGs is probably because they are too simple
[quoted text clipped - 5 lines]
>At the least, they could have pointed him toward an article or even a
>beginning manual for some help.

There is a subtle difference between explaining a phenomenon
- and agreeing with the reasons behind it

I, personally, do not accept any responsibility for VBdotNetters
behaviour
Steve Gerrard - 29 Feb 2004 17:55 GMT
> > For the microsoft news server, try these newsgroups...
> >
[quoted text clipped - 5 lines]
> this group though because the ones you listed never answer my post this is
> the only post with people who actually help me.

I don't think you really tried. I just took a look around, and didn't
see your question on any of them, or any other WStoreyII questions.

Here is a recent thread from microsoft.public.dotnet.languages.vb (the
group I would use):

http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&threadm=%23TIBfdi%24DHA.3
452%40TK2MSFTNGP11.phx.gbl&prev=/groups%3Fdq%3D%26num%3D25%26hl%3Den%26lr%3D%26i
e%3DUTF-8%26group%3Dmicrosoft.public.dotnet.languages.vb%26start%3D25


The question is pretty basic, and there seems to be users willing to
answer it.

Why not try posting this question there?
WStoreyII - 29 Feb 2004 07:59 GMT
> when using the instr()function i can check for a space by gong " " but how
> do i check for a number or letter not a particular number but just go to the
> first number or letter depending on what i need?
>
> WStoreyII
how would i use the remove function to remove all characters from a begin
point to the end point with out using the length function

for instance
mystring.remove(1,to end )
Rick Rothstein - 29 Feb 2004 09:18 GMT
> > when using the instr()function i can check for a space by gong " " but how
> > do i check for a number or letter not a particular number but just go to
[quoted text clipped - 7 lines]
> for instance
> mystring.remove(1,to end )

The version of VB that this newsgroup caters to does not have a "remove"
function; and if we were to dummy up a home-brewed function, it would never
be called with the syntax you showed. You must believe us when we tell you
this is the wrong newsgroup to post VB.NET questions in.

The main problem with asking VB.NET questions here is if you get a VB
Classic person (the **huge** majority of participants here) to answer your
question, that answer would more than likely be the wrong way to do whatever
you are asking about in VB.NET... even if it happens to work at all. There
is some backward tolerance for "old" code, but VB.NET has newer ways to
replace them, ways that are faster and more efficient for VB.NET to perform.
If you use the "old" ways in VB.NET, your programs will suffer. In other
cases, VB.NET won't be able to handle the "old" code at all. For example,
this VB6 statement won't work in VB.NET

    Dim SomeArray(100 To 150) As String

(I declared the Type as String, but any Type would do.) Also, VB6'ers make a
lot of use of Control Arrays... VB.NET doesn't have them. Of course, there
are ways to implement these concepts in VB.NET, but a regular VB6 programmer
won't post them for you because, quite simply, they simply don't know them.
You really will be doing yourself a disservice if you follow, or even
**try** to follow, the advice you will receive here.

Rick
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.