473,383 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

how to replace text in listbox to textbox

Dear Guru,
i have listbox data :

morning;Good Morning
evening;Good Evening
afternoon;Good Afternoon

i have text1 text2 and command1 so what i want is like this

when text1 enter morning command1 click text2 will show Good Morning
when text1 enter evening command1 click text2 will show Good Evening
when text1 enter afternoon command1 click text2 will show Good Afternoon

please help me thanks
Mar 22 '14 #1

✓ answered by kiad198

I hope this will help you!

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. If Text1.Text = "morning" Or Text1.Text = "Morning" Then
  3.    Text2.Text = "Good Morning"
  4. ElseIf Text1.Text = "afternoon" Or Text1.Text = "Afternoon" Then
  5.     Text2.Text = "Good Afternoon"
  6. ElseIf Text1.Text = "evening" Or Text1.Text = "Evening" Then
  7.     Text2.Text = "Good Evening"
  8. End If
  9. End Sub
  10.  

2 1169
I hope this will help you!

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. If Text1.Text = "morning" Or Text1.Text = "Morning" Then
  3.    Text2.Text = "Good Morning"
  4. ElseIf Text1.Text = "afternoon" Or Text1.Text = "Afternoon" Then
  5.     Text2.Text = "Good Afternoon"
  6. ElseIf Text1.Text = "evening" Or Text1.Text = "Evening" Then
  7.     Text2.Text = "Good Evening"
  8. End If
  9. End Sub
  10.  
Mar 22 '14 #2
Do you really need the listbox? From what you posted it appears that you don't. The previous answer doesn't use the listbox either.

If you don't need to use the listbox, the previous answer should work fine. The only change I would make is
Expand|Select|Wrap|Line Numbers
  1. If LCase(Text1.Text) = "morning" Then
  2.    Text2.Text = "Good Morning"
  3.  
If you have to use the listbox, all you need to do is:
1. loop through it using InStr to search for the string that is in TextBox1.Text
2. If found, copy the list item to a string variable and use InStr to find the location of the comma.
3. Use Right$ to get everything after the comma.
4. Put that into Text2.Text

Does that seem reasonable?
Apr 7 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Svennglenn | last post by:
I'm having problems replacing text in a unicode string. Here's the code: # -*- coding: cp1252 -*- titel = unicode("ä", "iso-8859-1") print titel print type(titel)
3
by: Andla Rand | last post by:
Hi, I would appreciate some directions on how to replace text as server controls. I'm currently reading text from a database and would like to build server logic based on specific information...
5
by: Casey | last post by:
Hello, Can someone give me specific code to replace text on a page using server side javascript? I need to use server-side because I need the output to be recognized in the final HTML so that...
2
by: rsquarev | last post by:
Hi, I am getting a problem regarding textboxes. In my application I am using a framework, which provides the page base for my application, It's just designing of page. But by using this I am not...
1
by: clem | last post by:
Hello, there is an asp.net textbox which contains some text. <asp:textbox runat="server"></asp:textbox> I select some part of the text with the mouse: how can i get that part of text in a...
6
by: aeris | last post by:
Hello, I'm a beginner of using C#. I'm creating a window application, May I know how to clear the default text on textbox when I click directly on the textbox? For example, the txtBox has the...
4
by: aeris | last post by:
Hello! I'm using C# to doing my window application. May I ask, how to write text on textbox after the default text is clear? I have setted the default text in textbox, when a user click on it,...
2
by: polluxsoftech | last post by:
i want to enter text in textbox by dropdown only when clicking on button i want that all this perform at client side by javascript.. this is dont in apsx page but i want it in .ascx this is...
1
by: Zfrost | last post by:
I'm really new to visual basic and I'm trying to write my first program. I need to replace the text in a textbox with the next line of a text file every time I click on the a button. Can someone...
1
by: misternaux | last post by:
Hi all, I would like to replace text in a Word template header, which is opened from MS Access. I can open the file just fine...: Set oApp = CreateObject("Word.Application") oApp.Visible =...
0
isladogs
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.