自定义类 [英] Custom Classes

查看:78
本文介绍了自定义类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试按照Sybex的Visual Basic语言开发人员手册中的

示例来了解自定义类。我想

我掌握了他们的意思,虽然目前很脆弱。

话虽如此,我想不出一个一个人的单一申请很明显

我需要进一步教育。有没有人有定制

课程的实际例子和他们的应用程序可以帮助我开阔视野?


非常感谢。

Keith。

I''ve been trying to get my head around custom classes by following the
example in the Visual Basic Language Developer''s Handbook by Sybex. I think
I have a handle on what they''re about, albeit a fragile one at the moment.
Having said that, I can''t think of a single application for one so obviously
I need educating further. Does anyone have any practical examples of custom
classes and their application that might help me broaden my horizons?

Many thanks.

Keith.

推荐答案

任何东西都可以是自定义类。想想任何有多个

变量的东西,你可以把它变成一个自定义类。


以雇员为例。我是一名员工,你可能是一名

员工。


在根目录下,所有员工都有一个名字,姓氏,生日,
SSN等。你可以存储这些变量,并且有一个

JasonLepack作为员工,或者一个KeithWilby作为员工。


另一个例如老虎机。每个老虎机都有一些

变量。

它有成本结构,支付结构,金额,数据

卷轴,卷轴的当前位置。


最重要的是老虎机有动作(功能),可以执行
。你可以存入Money,pullArm,fullPlay(

前面的按钮),payOut。


希望更有意义。


干杯,

Jason Lepack


Keith Wilby写道:
Anything can be a custom class. Think of anything that has multiple
variables and you can make it into a custom class.

Take an Employee for example. I am an employee, you presumably are an
employee.

At the root, all employees have a first name, last name, birthdate,
SSN, etc. You could store each of those variables and have a
JasonLepack as Employee, or a KeithWilby as Employee.

Another example is a slot machine. Each slot machine has a few
variables.
It has a cost structure, payout structure, amount of money in it, data
on the reels, current position of reels.

On top of that a slot machine has actions (functions) that can be
performed. You could depositMoney, pullArm, fullPlay (the button on
the front), payOut.

Hope that makes a little more sense.

Cheers,
Jason Lepack

Keith Wilby wrote:

我一直试图通过遵循Sybex的Visual Basic语言开发人员手册中的

示例来了解自定义类。我想

我掌握了他们的意思,虽然目前很脆弱。

话虽如此,我想不出一个一个人的单一申请很明显

我需要进一步教育。有没有人有定制

课程的实际例子和他们的应用程序可以帮助我开阔视野?


非常感谢。

基斯。
I''ve been trying to get my head around custom classes by following the
example in the Visual Basic Language Developer''s Handbook by Sybex. I think
I have a handle on what they''re about, albeit a fragile one at the moment.
Having said that, I can''t think of a single application for one so obviously
I need educating further. Does anyone have any practical examples of custom
classes and their application that might help me broaden my horizons?

Many thanks.

Keith.


Keith Wilby写道:
Keith Wilby wrote:

我一直在努力按照Sybex的Visual Basic语言开发人员手册中的

示例进行自定义类。我想b $ b我想知道他们的目的是什么,虽然现在很脆弱,但是b
。话虽如此,我不能想到一个单一的

申请,所以显然我需要进一步教育。

任何人都有自定义类的实际例子和他们的

应用程序可能会帮助我开阔眼界吗?

非常感谢。


基思。
I''ve been trying to get my head around custom classes by following the
example in the Visual Basic Language Developer''s Handbook by Sybex. I
think I have a handle on what they''re about, albeit a fragile one
at the moment. Having said that, I can''t think of a single
application for one so obviously I need educating further. Does
anyone have any practical examples of custom classes and their
application that might help me broaden my horizons?
Many thanks.

Keith.



我有类...


提供Windows文件浏览器对话框

创建并使用Outlook发送电子邮件

使用CDO创建并发送电子邮件

显示自定义消息对话框表格

(其他要深奥的麻烦的描述)


有时在一个类中有一堆相关的代码比在模块中只有函数和子例程更好

。类可以暴露某些东西而不暴露其他东西。您可以同时实例化一个类的多个

对象。因为它们被实例化为对象

你可以在其他函数和子例程之间传递它们。


我不是在使用它们的专家VBA中的访问和类具有一些

限制,但它们肯定有它们的位置。有些开发人员使用

课程比其他人更多,特别是如果他们来自编程

背景,其中面向对象被强调。


了解课程是很好的,并且能够深入了解你遇到的那些人,看看发生了什么,但如果你不能想到,就不要感到愧疚>
使用它们的数百种方法。在大多数情况下,普通的旧功能和

子程序以最佳方式解决问题。


-

Rick Brandt ,Microsoft Access MVP

电子邮件(视情况而定)至...

在Hunter dot com的RBrandt

I have classes that ...

Provides the Windows File Browser dialog
Creates and sends an Email using Outlook
Creates and send an Email using CDO
Displays a custom Message Dialog Form
(others that are to esoteric to bother describing)

There are times when having a bunch of related code in a class is better
than just having functions and sub-routines in a module. Classes can expose
certain things while not exposing others. You can instantiate multiple
objects of a Class at the same time. Since they are instantiated as objects
you can pass them around between other functions and sub-routines.

I''m not an expert at using them in Access and Classes in VBA have some
limitations, but they definitely have their place. Some developers uses
classes more than others especially if they came from a programming
background where object-oriented was stressed.

It is good to learn about Classes and be able to dig into those you
encounter and see what''s going on, but don''t feel guilty if you can''t think
of hundreds of ways to use them. In most cases plain old functions and
sub-routines solve the problem in the best fashion.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com




Keith Wilby写道:

Keith Wilby wrote:

我一直在尝试按照
Sybex的Visual Basic语言开发人员手册中的
示例。我想

我掌握了他们的意思,虽然目前很脆弱。

话虽如此,我想不出一个一个人的单一申请很明显

我需要进一步教育。有没有人有任何实际的自定义

类及其应用程序可以帮助我开阔视野?
I''ve been trying to get my head around custom classes by following the
example in the Visual Basic Language Developer''s Handbook by Sybex. I think
I have a handle on what they''re about, albeit a fragile one at the moment.
Having said that, I can''t think of a single application for one so obviously
I need educating further. Does anyone have any practical examples of custom
classes and their application that might help me broaden my horizons?



课程没有太多用途。主要的一个是让b / b
程序员/开发人员觉得他们已经到了。

我几乎从不使用自己的课程,但多年来我一直在辩护

它们对以下内容有用:

1.标准化由许多人开发的应用程序中的b
;例如一个追加类;

2.允许同时存在多个代码实例; for

表格关闭和打开时持久保存值的示例代码;

3.使用其创建和/或
初始化的对象或属性的代码耗费时间;例如一个数字到单词

程序使用数组和字符串。


如果你使用过具有
的表格,你已经广泛使用了类
模块,我希望你有。对于所有

范围和目的,表单模块是一个类模块。它具有初始化和

终止程序(form_open和form_close),

形式的控件或属性定义中的属性,并且可以有多个

实例。 IMO表格是一个非常优越的类。当看不见它

就像一个类一样。它可以根据需要显示(并且可以根据需要再次显示为
)以从用户获取输入,显示为进度条,

以显示消息等作为单个默认实体,它没有初始化

;我们可以jst调用Form_MYClass.DoSomething()

[DoSomething是一个公共程序]并猛击,bam已经完成。

There aren''t a lot of uses for classes. The major one is to make
programers/developers feel that they have arrived.
I use my own classes almost never but over the years I have defended
them as useful for:
1. standardizing procedures in an application developed by many
persons; for example an append class;
2. allowing for multiple instances of code to exist concurrently; for
example code that persisted values while forms were closed and opened;
3. code which used objects or properties whose creation and or
initialization were time consuming; for example a numerals to words
procedure where arrays and strings were used.

You have used classes extensively if you have used forms that have
modules, and I expect that you have. The form module is, for all
extents and purposes, a class module. It has initalization and
termination procedures (form_open and form_close), properties in the
form of controls or property definitions, and can have multiple
instances. IMO the form is a very superior Class. When invisible it
acts just like a class. It can be made visible on demand (and invisible
again on demand) to get input from the user, to show as progress bar,
to show a message, etc and as a single default entity it does not have
to be initialized; we can jst call Form_MYClass.DoSomething()
[DoSomething is a Public Procedure] and slam, bam it''s done.


这篇关于自定义类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆