hello all,
i need ur help..
i have 10 combobox & 10 textbox on windows forms
it's names like :
cmbsign1 txtdiscount1
cmbsign2 txtdiscount2
cmbsign3 txtdiscount3
cmbsign4 txtdiscount4
cmbsign5 txtdiscount5
i just make a for loop to fatch combobox and textbox's value -
dim sign as new combobox
-
dim discount as new textbox
-
-
j=1
-
For i = 0 To 10
-
sign = CType("cmbSign" & j, ComboBox)
-
-
txt.Name = "discount" & j
-
discount.Text = txt.Text
-
-
MsgBox(discount.Text)
-
-
discount.Text = ("txtdiscount" & j)
-
commission.Text = ("txtcommission" & j)
-
-
j = j + 1
-
Next
-
i.e.
=============== =
sign = CType(cmbSign1, ComboBox) if we do like this then work but i want
sign like
sign = CType("cmbSign" & j, ComboBox)
it gives error that can not convert from string to combobox..
can anybody help me?
any help will be appriciated..
thanking u in advanced..
6 1288
Hi ,
You can try this code for your requirement : - //variables for program
-
string txtName="";
-
string cmbName="";
-
string txtValue;
-
string cmbValue;
-
TextBox t1 = new TextBox();
-
ComboBox c1 = new ComboBox();
-
-
//For loop to get Textbox and Combo box values on the Form
-
for (int i = 1; i <= 10; i++)
-
{
-
-
//define textbox name
-
txtName = "txtdiscount" + i;
-
-
//define combobox name
-
cmbName = "cmbSign" + i;
-
-
//Get textbox control
-
t1 = (TextBox)this.Controls[txtName];
-
-
//Get combobox control
-
c1 = (ComboBox)this.Controls[cmbName];
-
-
//Get combo box value
-
cmbValue = c1.Text;
-
-
//Get textbox value
-
txtValue = t1.Text;
-
-
}
-
hi, shweta
first of all thanks..
u send me code in c# right?
i have to convert it into vb.net - Dim discounttxt As New TextBox
-
For i = 0 To 2
-
-
Dim b As String
-
Dim c As String
-
b = "txtdiscount" & j
-
i got the value of b - discounttxt = CType(Me.Controls(b), TextBox)
-
c = discounttxt.Text
-
-
Next
-
but can't get discounttxt.
i got value Nothing
i didn't get textbox control
do u have any idea?
thanking u in advanced....... .......
Hi,
For getting the value of discounttxt you have to add following code in your existing vb .net code : - Dim discounttxt as new TextBox
-
-
For i = 0 To 2
-
Dim b As String
-
Dim c As String
-
b = "txtdiscount" & j
-
-
'''''''Get textbox control here
-
discounttxt = CType(me.Controls(b),"TextBox")
-
-
'''''''''''Get the value of discount textbox
-
c = discounttxt.Text
-
Next
-
hi shweta
first of thanks, for replying me such fast...
thanks i had done according to u. but still i didn't get textbox as NOTHING
i just try following code..
i know it bit longer then u suggested..but will work now..code as follows: -
-
For ksign = 1 To 10
-
strsign = "cmbsign" & ksign
-
sign = Me.Controls("pnlCategoryInfo").Controls(strsign)
-
signvalue = sign.Text
-
Next
-
-
'for discount
-
For kdiscount = 1 To 10
-
strdisount = "txtdiscount" & kdiscount
-
discount = Me.Controls("pnlCategoryInfo").Controls(strdisount)
-
Next
-
-
'for commission
-
For kcommission = 1 To 10
-
strcommission = "txtcommission" & kcommission
-
commission = Me.Controls("pnlCategoryInfo").Controls(strcommission)
-
Next
-
once again thanks,
Hi,
Where are you getting error in this code?
Hello,
above pasted code is perfactly working..
i had done it..
thanks 4 ur help..
i told u that b4 one was not working..
any ways, have a great day ahead..
thanks again
Hi,
Where are you getting error in this code?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Cro |
last post by:
Dear Access Developers,
I am developing a form with 'default view' set to "continuous forms".
I am suffering with a problem I can't yet see a solution too.
Each record has many fields. Two fields I would like to add a little
extra functionality to are a check box and a combo box. More
explicitly, I would like the 'enabled' property of a combo box control
to be dependent on the value of a check box (a 'yes/no' field) in the
same...
|
by: Scott Davies |
last post by:
Hi,
I'm looking for some help on a small program that I'm trying to develop in
VB.NET. I'm having trouble getting the code that I've written to work, can
anyone shed some light as to where I'm going wrong.
The program has been written to do the following tasks:
- Select remote server
- Select from two specific services
|
by: Scott Davies |
last post by:
Hi,
I'm looking for some help on a small program that I'm trying to develop in
VB.NET.
The program I'm trying to develop needs to be able to do the following:
- Select remote server
- Select from two specific services
- Check the status of the server
|
by: Martin Henke |
last post by:
Dear all,
I've got a problem with my custom combo box.
When I select an entry from it, then I get the error message:
"An unhandled exception of type 'System.ArgumentOutOfRangeException'
occurred in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid
values."
|
by: Jake Montgomery |
last post by:
I am using .NET 2.0 forms and running on Windows XP SP2. When I have a
tooltip on a combo box, and the combo box is expanded (“dropped down”)
using the arrow, it will no longer display it’s tooltip, no matter how
long I hover. Even if I move off the control and back it will still not
display its tooltip. If I then go to another control that has tootips,
then back to the combobox, it will again display its tooltip, until the
next time it is...
| |
by: Nathan Laff |
last post by:
Why when I inherit a ComboBox and make no code changes, when I set the new
control DropDownStyle to dropDownList it appears different than the standard
ComboBox control on Vista?
In Windows Vista when this mode is set, the control is all one color
indicating that you can't type in it and looks really slick. How do i
reproduce this behavior?
|
by: Jerad Rose |
last post by:
I'm baffled by this -- is there not a typed object used for ComboBox Items?
Best I can tell, all of the methods for ComboBox that accept an Item are of
type Object. Why in the world is a common/standard .NET control accepting
an Object as a parameter type?
In Web Forms, there is a ListItem object that can be passed in to
add/retrieve objects from a DropDownItems collection. I searched Google
groups, and all the solutions I'm finding...
|
by: nityaprashant |
last post by:
hello..
i have grid view.. in that template column
i want to fatch product name form selected row..
i had done code like below..
but it fatch all row's product name one by one..
i want only product name for selected row..
|
by: Dan Tallent |
last post by:
In my application I have a form (Customer) that I want to be able to open
multiple copies at once. Within this form I have other forms that can be
opened. Example: ZipCode. When the user enters a zipcode that is unknown
this form will open. I don't want users to modify any of this customers
data until they close the zipcode form. Normally this can accomplished
using a modal form, however this prevents me from opening a new copy of...
|
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...
|
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,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |