473,763 Members | 7,541 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String Manipulating within List

Hi
I'm very new to VB (using VB6)
I have two lists one blank and one containing names in the format of surname
and then forename.I also have a combo box containing forenames.When I
select a forename from my combo box I need to add the corresponding surname
into the blank list box.What is the best way to do this? hope this make
sense

TIA

--
cheers dude
************
kinŽsole
************

Jul 17 '05 #1
12 5241

"KinŽsole" <ki******@NOSPA Mhotmail.com> wrote
I'm very new to VB (using VB6)
I have two lists one blank and one containing names in the format of surname
and then forename.I also have a combo box containing forenames.When I
select a forename from my combo box I need to add the corresponding surname
into the blank list box.What is the best way to do this? hope this make
sense

How did you build the lists? The combo and listbox both have an ItemData
property that may be of use when you are adding names. Post a small example
so we can see what you've got so far....

LFS


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #2
The easiest thing is for me to give you an example.
I have a list box (lstfullnames) a combo box (cmbforenames) and an empty
list box (lstsurnames)

In lstfullnames is the name Smith Bob. In cmbforenames is the name Bob. When
I click on Bob in the combo box in need to see if the name is in the
lstfullnames list and if it is then enter the surname (Smith) into the
lstsurname list box.

"Larry Serflaten" <Ab***@SpamBust ers.com> wrote in message
news:40******** **@corp.newsgro ups.com...

"KinŽsole" <ki******@NOSPA Mhotmail.com> wrote
I'm very new to VB (using VB6)
I have two lists one blank and one containing names in the format of surname and then forename.I also have a combo box containing forenames.When I
select a forename from my combo box I need to add the corresponding surname into the blank list box.What is the best way to do this? hope this make
sense

How did you build the lists? The combo and listbox both have an ItemData
property that may be of use when you are adding names. Post a small

example so we can see what you've got so far....

LFS


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----

Jul 17 '05 #3
You're missing the point. You will learn more if you show us what you've
attempted so we can comment and straighten you out in your handling of the
code. Just handing you an answer won't teach you anything. We understand
what you want, now let's see the source you've tried in order to achieve the
result.

--

Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
"KinŽsole" <ki******@NOSPA Mhotmail.com> wrote in message
news:b2******** *************** *******@news.te ranews.com...
: The easiest thing is for me to give you an example.
: I have a list box (lstfullnames) a combo box (cmbforenames) and an empty
: list box (lstsurnames)
:
: In lstfullnames is the name Smith Bob. In cmbforenames is the name Bob.
When
: I click on Bob in the combo box in need to see if the name is in the
: lstfullnames list and if it is then enter the surname (Smith) into the
: lstsurname list box.
:
: "Larry Serflaten" <Ab***@SpamBust ers.com> wrote in message
: news:40******** **@corp.newsgro ups.com...
: >
: > "KinŽsole" <ki******@NOSPA Mhotmail.com> wrote
: >
: > > I'm very new to VB (using VB6)
: > > I have two lists one blank and one containing names in the format of
: surname
: > > and then forename.I also have a combo box containing forenames.When I
: > > select a forename from my combo box I need to add the corresponding
: surname
: > > into the blank list box.What is the best way to do this? hope this
make
: > > sense
: >
: >
: > How did you build the lists? The combo and listbox both have an
ItemData
: > property that may be of use when you are adding names. Post a small
: example
: > so we can see what you've got so far....
: >
: > LFS
: >
: >
: >
: >
: > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
: > http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
: > -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
:
:
Jul 17 '05 #4
OK here's my code so far.This works if I have both surname and forename in
the forename combo box.I don't know how to Manipulate the full name in the
list to allow me to match just the first name.
Thanks for any help.
Option Explicit

Private Sub cmbForenames_Cl ick()
Dim namestr, namestr1, namestr2, namestr3, output, value As String
Dim num, number, count As Integer
Dim flag As Boolean

Let number = lstFullNames.Li stCount
Let num = cmbForenames.Li stIndex
Let namestr = cmbForenames.Li st(num)

Let namestr = LTrim$(namestr)

Let namestr = RTrim$(namestr)

Let namestr = UCase(Left$(nam estr, 1)) + Right$(namestr, Len(namestr) -
1)

For count = 0 To number

If lstFullNames.Li st(count) = namestr Then
flag = True

End If

Next count
If flag = False Then
MsgBox ("name is not in the list")
Else
Let namestr2 = Len(namestr)
Let namestr1 = InStr(1, namestr, " ")
Let namestr3 = Left$(namestr, namestr1)
lstsurnames.Add Item (namestr3)

End If

End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

"Randy Birch" <rg************ @mvps.org> wrote in message
news:ed******** *************@t wister01.bloor. is.net.cable.ro gers.com...
You're missing the point. You will learn more if you show us what you've
attempted so we can comment and straighten you out in your handling of the
code. Just handing you an answer won't teach you anything. We understand
what you want, now let's see the source you've tried in order to achieve the result.

--

Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
"KinŽsole" <ki******@NOSPA Mhotmail.com> wrote in message
news:b2******** *************** *******@news.te ranews.com...
: The easiest thing is for me to give you an example.
: I have a list box (lstfullnames) a combo box (cmbforenames) and an empty
: list box (lstsurnames)
:
: In lstfullnames is the name Smith Bob. In cmbforenames is the name Bob.
When
: I click on Bob in the combo box in need to see if the name is in the
: lstfullnames list and if it is then enter the surname (Smith) into the
: lstsurname list box.
:
: "Larry Serflaten" <Ab***@SpamBust ers.com> wrote in message
: news:40******** **@corp.newsgro ups.com...
: >
: > "KinŽsole" <ki******@NOSPA Mhotmail.com> wrote
: >
: > > I'm very new to VB (using VB6)
: > > I have two lists one blank and one containing names in the format of
: surname
: > > and then forename.I also have a combo box containing forenames.When I : > > select a forename from my combo box I need to add the corresponding
: surname
: > > into the blank list box.What is the best way to do this? hope this
make
: > > sense
: >
: >
: > How did you build the lists? The combo and listbox both have an
ItemData
: > property that may be of use when you are adding names. Post a small
: example
: > so we can see what you've got so far....
: >
: > LFS
: >
: >
: >
: >
: > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
: > http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
: > -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
:
:

Jul 17 '05 #5

"KinŽsole" <ki******@NOSPA Mhotmail.com> wrote
OK here's my code so far.This works if I have both surname and forename in
the forename combo box.I don't know how to Manipulate the full name in the
list to allow me to match just the first name.


I already asked, how are you building the lists? What you posted did not
show any names....

REF:
: "Larry Serflaten" wrote
: >
: > How did you build the lists? The combo and listbox both have an ItemData
: > property that may be of use when you are adding names. Post a small example
: > so we can see what you've got so far....



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #6
> Dim namestr, namestr1, namestr2, namestr3, output, value As String
Dim num, number, count As Integer
For the above two lines from your posted code, only 'value' is a String and
'count' an Integer... all other variables are declared as Variants. In VB,
you must specify the type of **each** variable individually.

Let number = lstFullNames.Li stCount
Let num = cmbForenames.Li stIndex
Let namestr = cmbForenames.Li st(num)
<<<etc>>>


VB does not require the use of the Let keyword to assign values to variables
or arrays. You can save yourself some typing by leaving it out.
Rick - MVP
Jul 17 '05 #7

"KinŽsole" <ki******@NOSPA Mhotmail.com> wrote
OK here's my code so far.


Just for your future reference:

When you are looking for help with a problem, it often is beneficial
to work up a small demo to reproduce the problem so that others
can copy and paste the code into VB, to see it on their system.

Some questions don't need a code example (Like; Where is the Help file?)
but those that are syntax or logic related often do need a example.
Also, it often happens, that in the process of building a smaller demo
of the problem, that the answer becomes apparent, and the problem is
solved before it is even posted. It is a learning experience to break
some problem down to just the bare necessities, and if you can't solve
it then, you'll have a small demo to post for others to help find the
answer. Thats why I ask for example code, it is far easier for you to
show me the problem, than for me to guess at what you're doing,
and sometimes the answer becomes apparent just by building the demo.

Of course, another reason is because myself and other regular posters
are also on the look out for students trying to get someone to do their
homework! ;-) If the student shows their work, adding a tweek here
or there is generally enough to get through the 'problem'.

LFS


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #8
As I say I an very new to VB.
The lists are just constructed at design time.
It is my collage homework but I have reached a point where I am stuck.I can
not figure out how to search for part of a string i.e forename within a
list.I know I need to some how remove the surname form the fullname list but
don't know how.
I thing I need to use ' INSTR' to find the space then use RIGHT$ to remove
the surname but I can get this to work for each entry in the list.
I'm only looking for a pointer!

cheers

"Larry Serflaten" <Ab***@SpamBust ers.com> wrote in message
news:40******** @corp.newsgroup s.com...

"KinŽsole" <ki******@NOSPA Mhotmail.com> wrote
OK here's my code so far.


Just for your future reference:

When you are looking for help with a problem, it often is beneficial
to work up a small demo to reproduce the problem so that others
can copy and paste the code into VB, to see it on their system.

Some questions don't need a code example (Like; Where is the Help file?)
but those that are syntax or logic related often do need a example.
Also, it often happens, that in the process of building a smaller demo
of the problem, that the answer becomes apparent, and the problem is
solved before it is even posted. It is a learning experience to break
some problem down to just the bare necessities, and if you can't solve
it then, you'll have a small demo to post for others to help find the
answer. Thats why I ask for example code, it is far easier for you to
show me the problem, than for me to guess at what you're doing,
and sometimes the answer becomes apparent just by building the demo.

Of course, another reason is because myself and other regular posters
are also on the look out for students trying to get someone to do their
homework! ;-) If the student shows their work, adding a tweek here
or there is generally enough to get through the 'problem'.

LFS


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----

Jul 17 '05 #9
sorry that should read " but I can get this to work for each entry in the
list."

cheers
"KinŽsole" <ki******@NOSPA Mhotmail.com> wrote in message
news:0a******** *************** *******@news.te ranews.com...
As I say I an very new to VB.
The lists are just constructed at design time.
It is my collage homework but I have reached a point where I am stuck.I can not figure out how to search for part of a string i.e forename within a
list.I know I need to some how remove the surname form the fullname list but don't know how.
I thing I need to use ' INSTR' to find the space then use RIGHT$ to remove
the surname but I can get this to work for each entry in the list.
I'm only looking for a pointer!

cheers

"Larry Serflaten" <Ab***@SpamBust ers.com> wrote in message
news:40******** @corp.newsgroup s.com...

"KinŽsole" <ki******@NOSPA Mhotmail.com> wrote
OK here's my code so far.


Just for your future reference:

When you are looking for help with a problem, it often is beneficial
to work up a small demo to reproduce the problem so that others
can copy and paste the code into VB, to see it on their system.

Some questions don't need a code example (Like; Where is the Help file?)
but those that are syntax or logic related often do need a example.
Also, it often happens, that in the process of building a smaller demo
of the problem, that the answer becomes apparent, and the problem is
solved before it is even posted. It is a learning experience to break
some problem down to just the bare necessities, and if you can't solve
it then, you'll have a small demo to post for others to help find the
answer. Thats why I ask for example code, it is far easier for you to
show me the problem, than for me to guess at what you're doing,
and sometimes the answer becomes apparent just by building the demo.

Of course, another reason is because myself and other regular posters
are also on the look out for students trying to get someone to do their
homework! ;-) If the student shows their work, adding a tweek here
or there is generally enough to get through the 'problem'.

LFS


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----


Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
7939
by: lamar_air | last post by:
I need a piece of code that takes a string like this string1 = "aaa/bbb/ccc/dd" and extracts a string containting the character after the last "/" So for this example the result would be "dd" like this: for i=0; string1.right(i) != '/'; i++ result = string1.mid(i, string1.length())
10
2379
by: jt | last post by:
I'm needing to take a binary string start at a certain position and return a pointer from that postion to the end of the binary stirng. something like this: char bstr; char *pos; pos=mid(bstr,35); / *return a pointer of the rest of the binary string starting at element 35 */
23
9517
by: comp.lang.tcl | last post by:
I have a TCL proc that needs to convert what might be a list into a string to read consider this: ]; # OUTPUTS Hello World which is fine for PHP ]; # OUTPUT {{-Hello}} World, which PHP will print literally as {{-Hello}} World, instead of
2
4211
by: shihaoran | last post by:
I really need help with one my program; it is about arraylist; I do not get it. Can someone please help me with it? Here's the instruction: 1. Your instructor will provide you with a text file, (numbers.txt), containing a large (N <= 1000) number of integers. The integers range in value from 0 to 100. The text file has been created with one value on each line. Due to the potential for the sum of the numbers to be very large, you...
4
13205
by: shapper | last post by:
Hello, How can I transform a Generic List(Of String) to a string as follows: "value1,value2,value3,value4, ..." Thanks, Miguel
9
2682
by: | last post by:
I am interested in scanning web pages for content of interest, and then auto-classifying that content. I have tables of metadata that I can use for the classification, e.g. : "John P. Jones" "Jane T. Smith" "Fred Barzowsky" "Department of Oncology" "Office of Student Affairs" "Lewis Hall" etc. etc. etc. I am wondering what the efficient way to do this in code might be. The dumb and brute-force way would be to loop through the content...
7
2378
by: Donn Ingle | last post by:
Hi, I really hope someone can help me -- I'm stuck. I have written three versions of code over a week and still can't get past this problem, it's blocking my path to getting other code written. This might be a little hairy, but I'll try to keep it short. Situation: I want to pass a string to a function which will parse it and generate objects in a list.
4
1623
by: Wilbert Berendsen | last post by:
Hi, is it possible to manipulate class attributes from within a decorator while the class is being defined? I want to register methods with some additional values in a class attribute. But I can't get a decorator to change a class attribute while the class is still being defined. Something like: class Parser(object): regexps =
6
2502
by: Alexnb | last post by:
Uhm, "string" and "non-string" are just that, words within the string. Here shall I dumb it down for you? string = "yes text1 yes text2 yes text3 no text4 yes text5+more Text yes text6 no text7 yes text8" It doesn't matter what is in the string, I want to be able to know exactly how many "yes"'s there are. I also want to know what is after each, regardless of length. So, I want to
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9997
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7366
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.