Hello,
I am trying to write a function that will return the value to be stored from
any control based on the control's type. So for text boxes and labels it
would return the text value, for list boxes the ListIndex, for combos maybe
the Items data etc. with several possible return types (string, int etc).
My function (that does not work) is:
Public Function SaveValue(ByVal ctrlIn As Control) As VariantType
If (TypeOf ctrlIn Is TextBox) Then
SaveValue = ctrlIn.Text
End If
If (TypeOf ctrlIn Is Label) Then
SaveValue = ctrlIn.Text
End If
If (TypeOf ctrlIn Is ComboBox) Then
Dim cbTemp As ComboBox = CType(ctrlIn, ComboBox)
SaveValue = cbTemp.Selected Index
End If
End Function
I played with variant type thinking it might work - but cannot get the
function to perform as I want. Any ideas? Thanks. 3 1342
Return Type Object
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Mike Hoff" <mi**@home.co m> wrote in message
news:10******** *****@corp.supe rnews.com... Hello,
I am trying to write a function that will return the value to be stored
from any control based on the control's type. So for text boxes and labels it would return the text value, for list boxes the ListIndex, for combos
maybe the Items data etc. with several possible return types (string, int etc). My function (that does not work) is:
Public Function SaveValue(ByVal ctrlIn As Control) As VariantType
If (TypeOf ctrlIn Is TextBox) Then SaveValue = ctrlIn.Text End If
If (TypeOf ctrlIn Is Label) Then SaveValue = ctrlIn.Text End If
If (TypeOf ctrlIn Is ComboBox) Then Dim cbTemp As ComboBox = CType(ctrlIn, ComboBox) SaveValue = cbTemp.Selected Index End If
End Function
I played with variant type thinking it might work - but cannot get the function to perform as I want. Any ideas? Thanks.
Thanks - works perfectly!
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. Return Type Object
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Mike Hoff" <mi**@home.co m> wrote in message news:10******** *****@corp.supe rnews.com... Hello,
I am trying to write a function that will return the value to be stored from any control based on the control's type. So for text boxes and labels
it would return the text value, for list boxes the ListIndex, for combos maybe the Items data etc. with several possible return types (string, int
etc). My function (that does not work) is:
Public Function SaveValue(ByVal ctrlIn As Control) As VariantType
If (TypeOf ctrlIn Is TextBox) Then SaveValue = ctrlIn.Text End If
If (TypeOf ctrlIn Is Label) Then SaveValue = ctrlIn.Text End If
If (TypeOf ctrlIn Is ComboBox) Then Dim cbTemp As ComboBox = CType(ctrlIn, ComboBox) SaveValue = cbTemp.Selected Index End If
End Function
I played with variant type thinking it might work - but cannot get the function to perform as I want. Any ideas? Thanks.
Glad to be of help
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Mike Hoff" <mi**@home.co m> wrote in message
news:10******** *****@corp.supe rnews.com... Thanks - works perfectly!
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. .. Return Type Object
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Mike Hoff" <mi**@home.co m> wrote in message news:10******** *****@corp.supe rnews.com... Hello,
I am trying to write a function that will return the value to be
stored from any control based on the control's type. So for text boxes and labels it would return the text value, for list boxes the ListIndex, for combos
maybe the Items data etc. with several possible return types (string, int etc). My function (that does not work) is:
Public Function SaveValue(ByVal ctrlIn As Control) As VariantType
If (TypeOf ctrlIn Is TextBox) Then SaveValue = ctrlIn.Text End If
If (TypeOf ctrlIn Is Label) Then SaveValue = ctrlIn.Text End If
If (TypeOf ctrlIn Is ComboBox) Then Dim cbTemp As ComboBox = CType(ctrlIn, ComboBox) SaveValue = cbTemp.Selected Index End If
End Function
I played with variant type thinking it might work - but cannot get the function to perform as I want. Any ideas? Thanks.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: googleboy |
last post by:
I didn't think this would be as difficult as it now seems to me.
I am reading in a csv file that documents a bunch of different info on
about 200 books, such as title, author, publisher, isbn, date and
several other bits of info too.
I can do a simple sort over the first field (title as it turns out),
and that is fine as far as it gets:
|
by: Richard Hollenbeck |
last post by:
I'm trying to write some code that will convert any of the most popular
standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan
1908) and compare the first with the second and calculate days, months, and
years. This is not for a college course. It's for my own personal
genealogy website. I'm stumped about the code. I'm working on it but not
making much progress. Is there any free code available anywhere? I know it...
|
by: Leslaw Bieniasz |
last post by:
Cracow, 20.09.2004
Hello,
I need to implement a library containing a hierarchy of classes
together with some binary operations on objects. To fix attention,
let me assume that it is a hierarchy of algebraic matrices with the
addition operation. Thus, I want to have a virtual base class
class Matr;
|
by: Iced Crow |
last post by:
In C# I know that you can use delegates to assing
multiple addresses of sub and functions to a delegate and
have it fire multiple procedures...
How do I do this in VB? I only know of assigning a
single method to a delegate in VB.NET. I want to use it
as in C#... to fire multiple events.
Thanks in advance!
|
by: Nikolay Petrov |
last post by:
How can I return multiple values from a custom function?
TIA
| |
by: Ian Bicking |
last post by:
I got a puzzler for y'all. I want to allow the editing of functions
in-place. I won't go into the reason (it's for HTConsole --
http://blog.ianbicking.org/introducing-htconsole.html), except that I
really want to edit it all in-process and in-memory. So I want the
identity of the function to remain the same, even as I edit the body
and hopefully the signature too.
Well, the reason is that I want to edit any function object, without...
|
by: aleksandar.ristovski |
last post by:
Hello all,
I have been thinking about a possible extension to C/C++ syntax.
The current syntax allows declaring a function that returns a value:
int foo();
however, if I were to return more than one value, for example three
int-s, I would have to change my "logic" and pass the references to my
|
by: computerwolf8 |
last post by:
I have a file where I know the lines go as follows:
string
long
string
int
int
string
double
|
by: ADezii |
last post by:
The incentive for this Tip was an Article by the amazing Allen Browne - I considered it noteworthy enough to post as The Tip of the Week in this Access Forum.
Original Article by Allen Browne
Traditionally, one has always thought that Functions can only return a single value, and for the most part that was true. Ever since Access 95, we gained the new functionality, through VBA, to have Functions return an entire Structure of values. A User...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: 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();...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |