|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 31 楼』:
使用 LLM 解释/回答一下
Who Can Tell Me把图片上传到什么地方,不会每天都变更一个链接地址,以至于引用的时候不会失效?我在雅虎空间、百度空间都试了,老是天天换,搞得我很机械。<img src="images/smilies/face-wink.png" align="absmiddle" border="0">
Last edited by Billunique on 2007-4-26 at 01:40 AM ]
Who Can Tell Me where to upload pictures so that the link address doesn't change every day, so that when citing, it won't become invalid? I've tried Yahoo Spaces and Baidu Spaces, but they always change every day, which is very mechanical. ;)
Last edited by Billunique on 2007-4-26 at 01:40 AM ]
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-4-26 01:38 |
|
|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 32 楼』:
使用 LLM 解释/回答一下
%%总线%%
所谓总线,是计算机中各功能部件间传送信息的公共通道,是微型计算机的重要组成部分。它们可以是带状的扁平电缆线,也可以是印刷电路板上的一层极薄的金属连线。所有的信息都通过总线传送。根据所传送信息的内容与作用不同,总线可分为三类:
1.地址总线AB(Address Bus):在对存储器或I/O端口进行访问时,传送由CPU提供的要访问存储单元或I/O端口的地址信息,以便选中要访问的存储单元或I/O端口,是单向总线,其宽度决定了CPU寻址空间的大小。如8086的地址线为20根,则其寻址空间为2的20次方=1MB。而P4的地址线为36根,则其寻址空间为2的36次方=1GB*2的6次方=64GB。
2.数据总线DB(Data Bus):从存储器取指令或读/写操作数、对I/O端口进行读/写操作时,指令码或数据信息通过数据总线送往CPU或由CPU送出,是双向总线。其宽度决定了CPU一次传送的二进制的位数。(通常说的处理器的位数对应的是它)
3.控制总线CB(Control Bus):各种控制或状态信息通过控制总线由CPU送往有关部件,或者从有关部件送往CPU。CB中每根线的传送方向是一定的。
Last edited by Billunique on 2007-4-26 at 03:46 AM ]
%%Bus%%
The so-called bus is a common channel for transmitting information among various functional components in a computer, and it is an important part of a microcomputer. They can be ribbon-shaped flat cables or extremely thin metal connections on a layer of a printed circuit board. All information is transmitted through the bus. According to the different contents and functions of the transmitted information, the bus can be divided into three categories:
1. Address Bus AB (Address Bus): When accessing the memory or I/O port, it transmits the address information of the memory unit or I/O port to be accessed provided by the CPU, so as to select the memory unit or I/O port to be accessed. It is a one-way bus, and its width determines the size of the CPU's addressing space. For example, the 8086 has 20 address lines, so its addressing space is 2 to the power of 20 = 1MB. And the P4 has 36 address lines, so its addressing space is 2 to the power of 36 = 1GB * 2 to the power of 6 = 64GB.
2. Data Bus DB (Data Bus): When fetching instructions from the memory or performing read/write operations on operands, and performing read/write operations on the I/O port, the instruction code or data information is sent to the CPU through the data bus or sent out by the CPU. It is a bidirectional bus. Its width determines the number of binary bits transmitted by the CPU at one time. (The number of bits of the processor usually referred to corresponds to it)
3. Control Bus CB (Control Bus): Various control or status information is sent from the CPU to relevant components or from relevant components to the CPU through the control bus. The transmission direction of each line in the CB is fixed.
Last edited by Billunique on 2007-4-26 at 03:46 AM ]
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-4-26 02:01 |
|
|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 33 楼』:
使用 LLM 解释/回答一下
我回来了!<img src="images/smilies/face-smile-big.png" align="absmiddle" border="0">最近好忙啊~忙得忽略了学习,这样可不好。要知道知识是需要巩固的,要常记常用才能成为自己受用的知识。
其实对于DOS的学习我只是停于表面,非常肤浅。照理应该深究才有所成。但限于时间和目前的应用环境,我不想再回头重来一遍了。我知道学习应该有重点,在耐性,不能老是蜻蜓点水过一遍,但总又有意无意地犯这个毛病。不管怎样,学习要进行下去,下一步学什么呢?
偶然间进入electronixtar的帖子“批处理与其他语言混合编程”( http://www.cn-dos.net/forum/viewthread.php?tid=26819),在WIKI里一段简单代码让我来了点感觉。既然现在无法很清晰地界定学习目标,那先试探吧。弄一个相对简单而且常用的——VBS,好歹Windows横行天下。学习VBS,从下面这段代码开始:
echo msgbox 3^>2 >v.vbs
cscript v.vbs
执行之后会弹出一个Windows对话框,主体内容显示“True”,再加一个“确定”按钮。这就是同属Microsoft的好处,省却多少代码。
I'm back! :D I've been really busy lately~ So busy that I neglected my studies, which isn't good. You know that knowledge needs to be reinforced; it has to be often remembered and used to become knowledge that benefits you.
Actually, my study of DOS is just at the surface, very superficial. Logically, I should delve deeper to achieve something. But limited by time and the current application environment, I don't want to start over again. I know that learning should have priorities and patience; I can't always just skim through things, but I always inadvertently make this mistake. Anyway, learning has to go on. What should I study next?
Accidentally entering electronixtar's post " Mixed Programming of Batch Processing and Other Languages" ( http://www.cn-dos.net/forum/viewthread.php?tid=26819), a simple code in WIKI gave me some inspiration. Since I can't clearly define the learning goal right now, let's start with a trial. Let's make something relatively simple and commonly used - VBS, after all, Windows is everywhere. To learn VBS, start with the following code:
echo msgbox 3^>2 >v.vbs
cscript v.vbs
After execution, a Windows dialog box will pop up, with the main content showing "True" and an "OK" button. This is the benefit of being from the same Microsoft family, saving a lot of code.
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-5-14 12:04 |
|
|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 34 楼』:
使用 LLM 解释/回答一下
经典教程里的一段代码--把VBS插在HTML页面中的一个示例:
<HTML>
<HEAD>
<TITLE>测试按钮事件</TITLE>
</HEAD>
<BODY>
<FORM NAME="Form1">
<INPUT TYPE="Button" NAME="Button1" VALUE="单击">
<SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript">
MsgBox "按钮被单击!"
</SCRIPT>
</FORM>
</BODY>
</HTML>
A segment of code from a classic tutorial — an example of inserting VBS into an HTML page:
<HTML>
<HEAD>
<TITLE>Test Button Event</TITLE>
</HEAD>
<BODY>
<FORM NAME="Form1">
<INPUT TYPE="Button" NAME="Button1" VALUE="Click">
<SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript">
MsgBox "The button is clicked!"
</SCRIPT>
</FORM>
</BODY>
</HTML>
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-5-14 18:44 |
|
|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 35 楼』:
使用 LLM 解释/回答一下
不管三七二一,先把这么几段话记下再说:(挺有启发性的)
基于组件开发(Component-Based Development,简写为CBD)是综合多种优秀设计思想和实践的产物,诸如面向对象开发、契约式设计、模型驱动的开发、分离考虑、软件系统架构设计等。CBD的目标是改进软件开发的过程,手段是通过一些预先构建的软件组件来组装成新的软件,而不是从头开发。通过对复用的强调,CBD达到了可观的开发效率和品质。Delphi组件、COM+组件、CORBA组件、JavaBeans和EJB等都是众所周知的一些组件模型。
组件和控件:
在.NET框架中,组件是指实现System.ComponentModel.IComponent接口的一个类,或从实现IComponent的类中直接或间接导出的类。在编程中,“组件”这个术语通常用于可重复使用并且可以和其他对象进行交互的对象。.NET框架组件满足这些一般要求,另外还提供诸如控制外部门资源和设计时支持等功能。
控件是提供(或实现)用户界面(UI)功能的组件。.NET框架为控件提供两个基类:一个用于客户端Windows窗体控件,另一个用于ASP.NET服务器控件。它们是System.Windows.Forms.Control和System.Web.UI.Control。.NET框架类库中的所有控件都是直接或间接从这两个类导出的。System.Windows.Forms.Control从Component导出,它本身提供UI功能。System.Web.UI.Control实现IComponent,它提供结构,在这个结构上可以很方便地添加UI功能。
一句经典的话:每个控件都是一个组件,但并不是每个组件都是一个控件。
Last edited by Billunique on 2007-5-16 at 04:39 PM ]
Regardless of everything, just write down these few paragraphs first: (quite inspiring)
Component-Based Development (abbreviated as CBD) is a product integrating various excellent design ideas and practices, such as object-oriented development, contract design, model-driven development, separate consideration, software system architecture design, etc. The goal of CBD is to improve the software development process, and the means is to assemble new software through some pre-built software components instead of developing from scratch. By emphasizing reuse, CBD achieves considerable development efficiency and quality. Delphi components, COM+ components, CORBA components, JavaBeans, and EJB, etc., are some well-known component models.
Components and controls:
In the.NET framework, a component refers to a class that implements the System.ComponentModel.IComponent interface, or a class directly or indirectly derived from a class that implements IComponent. In programming, the term "component" usually refers to an object that can be reused and can interact with other objects. The.NET framework components meet these general requirements and also provide functions such as controlling external resources and design-time support.
A control is a component that provides (or implements) user interface (UI) functions. The.NET framework provides two base classes for controls: one for client Windows Forms controls and the other for ASP.NET server controls. They are System.Windows.Forms.Control and System.Web.UI.Control. All controls in the.NET framework class library are directly or indirectly derived from these two classes. System.Windows.Forms.Control is derived from Component and itself provides UI functions. System.Web.UI.Control implements IComponent and provides a structure on which UI functions can be easily added.
A classic sentence: Every control is a component, but not every component is a control.
Last edited by Billunique on 2007-5-16 at 04:39 PM ]
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-5-16 15:52 |
|
|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 36 楼』:
使用 LLM 解释/回答一下
☆VB程序的工作机制
Visual Basic是一种基于对象的程序设计语言。一个Visual Basic程序由众多的对象以及响应各种事件的代码组成。当用户对对象进行某些操作时,就产生特定的事件。对象在某些特定条件下也会自动产生事件。当事件产生时,Visual Basic程序就自动调用相应的代码来处理这些事件。可以说,应用程序在运行的过程当中,始终在等候事件的产生并做出响应,直到用户结束整个程序为止。
●[对象]
很多人只要一接触到“面向对象”这个词,就感觉特别难以理解。在日常口语中常用到“东西”这个词,可以简单地认为,所说的“东西”同这里的“对象”具有相同的意义。对象是很具体地存在着的一个事物,比如一支铅笔、一个发电机、一只老虎(如果用口语来表达,这些事物都是“东西”)。不难发现,铅笔也好,发电机也好,老虎也好,都是具有完整意义的一个事物:如果铅笔少了笔芯,也就不是铅笔了;如果发电机少了磁芯,它就发不出电来,也就不能称其为发电机了。
在日常生活中,是怎么区分“东西”的呢?首先,我们将事物分类。显然,我们不会将家用电脑同车床混淆在一起,因为它们分别属于两类事物。而后,对于同一类的物体,可以通过其不同的特征区分不同的个体。比如两支铅笔,它们都是同一类物体,但可能通过颜色来区分:一支是黄色的,另一支是红色的。
于是,在面向对象理论中,用“类”这个词来表示对象的不同类型,用属性和方法来表示同种对象的不同特征。属性是对象的静态特征。比如颜色(这是静态的)是铅笔的属性,铅笔的颜色可以是黑的,也可以是红的或蓝的。方法是对象的动态特征。比如发电(这是一种动作,是动态的)就是发电机的方法。对象的方法是通过外部的事件来触发的。像发电机的发电方法,只有在操作人员允许发电机运转后,发电机的发电方法才被触发,进入发电状态。
在Visual Basic中,窗体、控件、菜单等都是对象。在例子程序“欢迎进入VB世界”中使用的对象有:一个窗体、两个命令按钮控件和一个标签控件。(你可以想象出来,这里照书上的行文来)
以命令按钮控件为例。在例子程序中,使用了两个按钮控件。这两个对象虽然都是命令按钮(即属于同一类),但是它们具有不同的Caption属性:一个是“开始”,一个是“退出”。也具有不同的Name属性:一个是“Command1”,另一个是“Command2”。命令按钮控件有很多方法,比如“移动”方法,当命令按钮控件在窗体上的位置需要改变时,我们就调用命令按钮的“移动”方法来实现。
显然,在Visual Basic编程中,应用程序的用户界面是由很多与用户界面有关的对象组成的。所以,在编写Visual Basic程序时,要做的第一件事就是准备好程序中所要用到的对象。(准备“米”--|东西|下饭)
●[事件驱动机制]
Visual Basic程序的主体是众多的对象,也就是窗体、控件、菜单等。当用户在某个对象上进行某行操作,比如在命令按钮上进行鼠标单击,就会在这个命令按钮对象上激发一个鼠标单击事件。一般来说,用户的操作都是有目的的,应用程序应该响应用户的操作,也就是说,程序员应该编写代码处理这些事件。
实际上,Visual Basic程序的运行过程就是对事件的处理过程。程序运行时,各种不同的对象会产生很多不同的事件。这些事件有一些是由用户的操作引起的,另一些是在某种条件下对象自己产生的(比如“定时器时间到”事件)。程序员分别为各种不同的事件编写处理代码。在没有事件发生时,程序就什么也不做。这就是所说的事件驱动机制。
Visual Basic的这种基于对象的事件驱动机制,是简化Windows程序设计的法宝。在这种机制下,设计一个Visual Basic程序只需遵循如下步骤:
1)设计程序的用户界面,也就是放置各种对象。
2)定义用户界面中各个对象的属性,比如颜色、标题等。
3)定义各个可能用到的事件。
4)给事件编写相应的代码。
其中,前3个步骤是与界面设计有关的步骤。程序员只需使用VB的可视化工具即可完成这些设计,根本无需编写任何代码。(手编当然也可以,VBS就得手编啊)第4个步骤才是实现程序功能的编码工作。这样,程序员就可以将大部分精力放在功能的实现上。至于界面是怎么捕获用户操作,怎么发出事件,怎么调用程序员编写的事件处理代码的,根本无需关心,VB已经为用户设计好了这些事。
Last edited by Billunique on 2007-5-16 at 06:08 PM ]
### ☆Working Mechanism of VB Programs
Visual Basic is an object-based programming language. A Visual Basic program consists of numerous objects and code that responds to various events. When a user performs certain operations on an object, a specific event is generated. Objects can also automatically generate events under certain specific conditions. When an event occurs, the Visual Basic program automatically calls the corresponding code to handle these events. It can be said that during the running process of the application, it is always waiting for the occurrence of events and responding to them until the user ends the entire program.
●
Many people feel particularly difficult to understand as soon as they come into contact with the term "object-oriented". The word "thing" is commonly used in daily spoken language, and it can be simply considered that the "thing" mentioned here has the same meaning as the "object" here. An object is a very specific existing thing, such as a pencil, a generator, a tiger (if expressed in spoken language, these things are all "things"). It is not difficult to find that whether it is a pencil, a generator, or a tiger, they are all a thing with complete meaning: if a pencil is missing the lead core, it is no longer a pencil; if a generator is missing the magnetic core, it cannot generate electricity and thus cannot be called a generator.
In daily life, how to distinguish "things"? First, we classify things. Obviously, we will not confuse a home computer with a lathe because they belong to two different types of things. Then, for objects of the same type, different individuals can be distinguished by their different characteristics. For example, two pencils, they are all objects of the same type, but they may be distinguished by color: one is yellow and the other is red.
Thus, in the object-oriented theory, the term "class" is used to represent different types of objects, and attributes and methods are used to represent different characteristics of the same type of objects. Attributes are the static characteristics of an object. For example, color (this is static) is an attribute of a pencil. The color of a pencil can be black, red, or blue. Methods are the dynamic characteristics of an object. For example, generating electricity (this is an action, which is dynamic) is a method of a generator. The method of an object is triggered by an external event. For example, the power generation method of a generator will only be triggered and enter the power generation state after the operator allows the generator to operate.
In Visual Basic, forms, controls, menus, etc. are all objects. The objects used in the example program "Welcome to the VB World" are: one form, two command button controls, and one label control. (You can imagine it, here it follows the text in the book)
Take the command button control as an example. In the example program, two button controls are used. Although these two objects are both command buttons (that is, belong to the same class), they have different Caption attributes: one is "Start" and the other is "Exit". They also have different Name attributes: one is "Command1" and the other is "Command2". The command button control has many methods, such as the "move" method. When the position of the command button control on the form needs to be changed, we call the "move" method of the command button to achieve it.
Obviously, in Visual Basic programming, the user interface of the application is composed of many objects related to the user interface. Therefore, the first thing to do when writing a Visual Basic program is to prepare the objects to be used in the program. (Prepare "rice"--|thing|to go with rice)
●
The main body of a Visual Basic program is numerous objects, that is, forms, controls, menus, etc. When a user performs an operation on an object, such as a mouse click on a command button, a mouse click event will be triggered on this command button object. Generally speaking, the user's operations are purposeful, and the application should respond to the user's operations, that is, the programmer should write code to handle these events.
In fact, the running process of a Visual Basic program is the process of handling events. When the program runs, various different objects will generate many different events. Some of these events are caused by user operations, and others are generated by the object itself under certain conditions (such as the "timer time is up" event). Programmers write processing code for various events respectively. When no event occurs, the program does nothing. This is the so-called event-driven mechanism.
This event-driven mechanism based on objects in Visual Basic is a magic weapon for simplifying Windows program design. Under this mechanism, to design a Visual Basic program, you only need to follow the following steps:
1) Design the user interface of the program, that is, place various objects.
2) Define the attributes of each object in the user interface, such as color, title, etc.
3) Define each possible event to be used.
4) Write corresponding code for the events.
Among them, the first 3 steps are steps related to interface design. Programmers can complete these designs only by using VB's visual tools, and no code needs to be written at all. (Of course, it can also be written manually, and VBS has to be written manually) The 4th step is the coding work to realize the program function. In this way, programmers can focus most of their energy on the realization of functions. As for how the interface captures user operations, how to issue events, and how to call the event handling code written by the programmer, there is no need to care. VB has already designed these things for the user.
Last edited by Billunique on 2007-5-16 at 06:08 PM ]
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-5-16 17:53 |
|
|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 37 楼』:
使用 LLM 解释/回答一下
过程
子过程(Sub procedure)是一个用来完成某一特定功能的程序块。如果一个程度中有多处需要使用相同的程度代码完成相同的事情,就可以将这段代码做成一个过程。在需要的时候,可以通过调用这个过程完成相应的任务。
函数过程(Function procedure)也是个能完成某一特定功能的程序块,它同子过程的区别在于函数能返回一个结果。
使用过程能使程序结构清晰,从而实现结构化和模块化程度的设计目标。
### Process
A sub procedure is a block of program code used to accomplish a specific function. If there are multiple places in a program where the same program code is needed to do the same thing, this piece of code can be made into a procedure. When needed, the corresponding task can be completed by calling this procedure.
A function procedure is also a block of program code that can accomplish a specific function. The difference between it and a sub procedure is that a function can return a result.
Using procedures can make the program structure clear, thus achieving the design goals of structured and modular programming.
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-5-17 17:52 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 38 楼』:
使用 LLM 解释/回答一下
Billunique兄涉猎很多啊,要是我可就不能同时应对了。呵呵
Brother Billunique has a wide range of interests. If it were me, I couldn't handle it all at the same time. Hehe
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2007-5-25 10:38 |
|
|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 39 楼』:
使用 LLM 解释/回答一下
惭愧惭愧,让ccwan兄见笑了!非涉猎广,实蒙头乱撞而已。学东西千万不可似我,学无所专,学无所长。就像那幅经典的漫画“挖井”一样,挖几把换一个地方,到头来始终挖不到自己的“井”。
Ashamed, ashamed. Let Brother ccwan laugh at me! It's not that I have a wide range of knowledge, but just groping in the dark. When learning things, you must never be like me, with no specific focus and no particular expertise. Just like that classic cartoon "Digging Wells", dig a few times and then change place, and in the end, you never dig your own "well".
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-5-29 15:01 |
|
|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 40 楼』:
使用 LLM 解释/回答一下
这段话挺好的:
变量就像一个容器,容器里面可以盛放一升液体或两升液体,也可以什么都不放。变量也是如此,它可以放一个数字、一个字符串,什么时候放多少东西,完全由程序的功能来决定。
(从专业的角度来说,变量是存储在内存中的用来代替所包含信息的地址的名字。变量,是一个代号。)
This passage is quite good:
Variables are like containers. A container can hold one liter of liquid or two liters of liquid, or it can hold nothing. It's the same with variables; they can hold a number, a string, and exactly what and how much to hold is entirely determined by the function of the program.
(From a professional perspective, a variable is a name that is stored in memory and represents the address of the information it contains. A variable is a code name.)
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-5-29 18:47 |
|
|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 41 楼』:
使用 LLM 解释/回答一下
获取输入
Prompting for information is easy: Just use InputBox. This function pops up a dialog box, and users can happily enter whatever you asked them to.
ask="Hey,what's your name?"
title="Who are you?"
answer=InputBox(ask,title)
If answer=vbEmpty Then
MsgBox "You want to cancel? Fine!"
WScript.Quit
ElseIf answer=""Then
MsgBox "You want to stay incognito,all right with me..."
Else
MsgBox "Welcome "&answer&"!"
End If
注:用户按下“Cancel"键时,传递的值为一个”empty"值,我们可以将其等同于常量“VbEmpty”。如果没有加入这层判断,而直接“Cancel”提交时,MsgBox会“尽力”地把“空值”转化为”空字符串”,这样的话“Cancel”键的作用就体现不出来了,表面上看就好像等同于传递了一个空字符串。
你可以用下面这段代码去体会上面的描述。
ask="Hey,what's your name?"
title="Who are you?"
default="??"
answer=InputBox(ask,title,default)
MsgBox "Welcome "&answer&"!"
Last edited by Billunique on 2007-6-14 at 11:01 AM ]
### Obtaining Input
Prompting for information is easy: Just use `InputBox`. This function pops up a dialog box, and users can happily enter whatever you asked them to.
```vb
ask = "Hey, what's your name?"
title = "Who are you?"
answer = InputBox(ask, title)
If answer = vbEmpty Then
MsgBox "You want to cancel? Fine!"
WScript.Quit
ElseIf answer = "" Then
MsgBox "You want to stay incognito, all right with me..."
Else
MsgBox "Welcome " & answer & "!"
End If
```
Note: When the user presses the "Cancel" key, the passed value is an "empty" value, which we can equate to the constant "VbEmpty". If this layer of judgment is not added and "Cancel" is directly submitted, the MsgBox will "try its best" to convert the "empty value" into an "empty string", so that the function of the "Cancel" key will not be reflected, and it will seem on the surface as if an empty string is passed.
You can use the following code to experience the above description.
```vb
ask = "Hey, what's your name?"
title = "Who are you?"
default = "??"
answer = InputBox(ask, title, default)
MsgBox "Welcome " & answer & "!"
```
Last edited by Billunique on 2007-6-14 at 11:01 AM ]
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-6-5 10:21 |
|
|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 42 楼』:
使用 LLM 解释/回答一下
检查输入
Prompting for information doesn’t necessarily mean you’ll get it. You can ask politely, because InputBox accepts anything the user types in. Therefore,after asking for information, you should check the entered information to make sure it is valid.(这里我们用 “is~”这个东西,它就相当于询问“请问你是不是~?”)
ask="What's your birthday?"
title="Let's see how old you are!"
Do
birthday=InputBox(ask,title)
If IsEmpty(birthday)Then
MsgBox "Hey! You could always lie to me to hide " _
&" your age! But ok, I quit!"
WScript.Quit
ElseIf Not IsDate(birthday) Then
MsgBox "You didn't enter a valid date! Try again!"
End If
Loop Until IsDate(birthday)
age_in_days=DateDiff("d",birthday,Date)
age_in_months=DateDiff("m",birthday,Date)
age_in_years=DateDiff("yyyy",birthday,Date)
day_born=WeekdayName(Weekday(birthday))
date_day=Day(birthday)
date_month=Month(birthday)
date_year=Year(Date)
this_years_birthday=DateSerial(date_year,date_month,date_day)
days_to_birthday=Abs(DateDiff("d",Date,this_years_birthday))
day_celebrating=WeekdayName(Weekday(this_years_birthday))
If this_years_birthday<Date Then
message="you celebrated your birthday "& days_to_birthday &" days ago"
ElseIf this_years_birthday=Date Then
message="Happy birthday!!"
Else
message=days_to_birthday &" days to go!"
End If
msg="This is your birthday analysis:" & vbCr
msg=msg+"You are born on "& birthday & vbCr
msg=msg+"You are " & age_in_years &" yrs old. That's" & vbCr
msg=msg &age_in_months &" months or " & age_in_days &" days!" &vbCr
msg=msg+"You were born on a " & day_born &vbCr
msg=msg+"This year's birthday is on " & this_years_birthday &vbCr
msg=msg+"It's a " &day_celebrating &vbCr
msg=msg+message
MsgBox msg
Last edited by Billunique on 2007-6-14 at 11:12 AM ]
### Checking Input
Prompting for information doesn't necessarily mean you'll get it. You can ask politely, because InputBox accepts anything the user types in. Therefore, after asking for information, you should check the entered information to make sure it is valid. (Here we use the thing called "is~", which is equivalent to asking "Are you ~?")
```code
'asking for a date
ask="What's your birthday?"
title="Let's see how old you are!"
'start a loop:
Do
birthday=InputBox(ask,title)
'check whether the user wants to quit:
If IsEmpty(birthday)Then
MsgBox "Hey! You could always lie to me to hide " _
&" your age! But ok, I quit!"
WScript.Quit
ElseIf Not IsDate(birthday) Then
'check whether birthday is really a date!
'complain and give another chance:
MsgBox "You didn't enter a valid date! Try again!"
End If
'loop until a valid date was retrieved
Loop Until IsDate(birthday)
'at this point,we have a valid date,good!
'do some fun calculations:
age_in_days=DateDiff("d",birthday,Date)
age_in_months=DateDiff("m",birthday,Date)
age_in_years=DateDiff("yyyy",birthday,Date)
day_born=WeekdayName(Weekday(birthday))
' DateDiff is a function to compare the interval between two dates. The first parameter is the comparison unit, and the result is the value of the first date minus the second date.
' Weekday is a function that returns the "day of the week number" (Sunday~Saturday:1~7)
' WeekdayName is a function that returns the "day of the week name"
'calculate this year's birthday
date_day=Day(birthday)
date_month=Month(birthday)
'use current year:
date_year=Year(Date)
' Day function returns the "day of the month number" (1~31)
' Month function returns the "month number" (1~12)
' Year function returns the specific "year number" (in the format of 2007)
' DateSerial function accepts three parameters, which should be valid values or expressions of year, month, and day respectively,
' and then rearranges them into a standard date format containing year, month, and day
this_years_birthday=DateSerial(date_year,date_month,date_day)
'use Abs to convert to positive numbers in case the birthday's already over:
days_to_birthday=Abs(DateDiff("d",Date,this_years_birthday))
day_celebrating=WeekdayName(Weekday(this_years_birthday))
' Because it's previous parameter - subsequent parameter, there may be a negative value, that is, the birthday hasn't arrived yet,
' so use Abs (Absolute) to get its absolute value.
'already over?
If this_years_birthday<Date Then
message="you celebrated your birthday "& days_to_birthday &" days ago"
ElseIf this_years_birthday=Date Then
message="Happy birthday!!"
Else
message=days_to_birthday &" days to go!"
End If
'output information
msg="This is your birthday analysis:" & vbCr
msg=msg+"You are born on "& birthday & vbCr
msg=msg+"You are " & age_in_years &" yrs old. That's" & vbCr
msg=msg &age_in_months &" months or " & age_in_days &" days!" &vbCr
msg=msg+"You were born on a " & day_born &vbCr
msg=msg+"This year's birthday is on " & this_years_birthday &vbCr
msg=msg+"It's a " &day_celebrating &vbCr
msg=msg+message
MsgBox msg
' Use the method of superimposing msg itself to achieve the final input effect, which is very typical, and you should master it.
```
Last edited by Billunique on 2007-6-14 at 11:12 AM ]
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-6-5 18:20 |
|
|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 43 楼』:
使用 LLM 解释/回答一下
仅需确认意见
In many cases, you don’t need text input. You just need a simple Yes-or-No decision. VBScript contains a very versatile tool that allows you to ask all kinds of simple questions. It’s called MsgBox—you’ve already used this function to display plain text information.
You can call a function using parentheses, and it will return a value. If you calla function as a procedure, without using parentheses, it will not return a value. MsgBox is a function. When you use it as a procedure, it will simply output information. If you want to base decisions on MsgBox dialog boxes, then use it as a function, and check which value MsgBox returned.
The easiest way to call MsgBox as a function looks like this:
result = MsgBox(“Do you agree?”)
MsgBox后面的参数,第一为内容,第二为显示按钮+语气标志+默认选择按钮,三为标题;后面的为帮助,基本不用。
例如我们可以这样用:
result = MsgBox(“Continue?”, vbYesNo+vbQuestion, “What now?”)
返回值则可以参照下图:
Last edited by Billunique on 2007-6-6 at 11:21 AM ]
Just Need to Confirm the Opinion
In many cases, you don’t need text input. You just need a simple Yes-or-No decision. VBScript contains a very versatile tool that allows you to ask all kinds of simple questions. It’s called MsgBox—you’ve already used this function to display plain text information.
You can call a function using parentheses, and it will return a value. If you call a function as a procedure, without using parentheses, it will not return a value. MsgBox is a function. When you use it as a procedure, it will simply output information. If you want to base decisions on MsgBox dialog boxes, then use it as a function, and check which value MsgBox returned.
The easiest way to call MsgBox as a function looks like this:
result = MsgBox(“Do you agree?”)
The parameters after MsgBox, the first is the content, the second is the display buttons + tone flags + default selected button, the third is the title; the following are for help, basically not used.
For example, we can use it like this:
result = MsgBox(“Continue?”, vbYesNo+vbQuestion, “What now?”)
The return value can be referred to in the following figure:
Last edited by Billunique on 2007-6-6 at 11:21 AM ]
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-6-6 10:45 |
|
|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 44 楼』:
使用 LLM 解释/回答一下
'get arguments as collection object
set args = WScript.Arguments
' check whether there are any arguments:
if args.Count = 0 then
'no arguments
MsgBox “You called this script directly, no arguments specified!”
else
for each argument in args
list = list & argument & vbCr
next
MsgBox “Here’s the list of arguments:” & vbCr & list
end if
用上面这段代码,可以造就一个“参数阅读器”,而且支持参数拖拽。拖进去后参数的信息便会一目了然。
这里涉及到set的用法,for each...next的用法,Arguments对象的Count方法;而最典型最值得借鉴的是那个list的用法。利用循环和list自身叠加的方法达到了很好的输出效果,要掌握。
'get arguments as collection object
set args = WScript.Arguments
' check whether there are any arguments:
if args.Count = 0 then
'no arguments
MsgBox “You called this script directly, no arguments specified!”
else
for each argument in args
list = list & argument & vbCr
next
MsgBox “Here’s the list of arguments:” & vbCr & list
end if
Using the above code, you can create a "argument reader" that also supports argument dragging. Once dragged in, the information of the arguments will be clear at a glance.
This involves the usage of set, the usage of for each...next, the Count method of the Arguments object; and the most typical and worthy of reference is the usage of that list. By using the loop and the method of superimposing the list itself, a good output effect is achieved, which should be mastered.
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-6-6 11:45 |
|
|
Billunique
中级用户
   菜鸟总动员
积分 259
发帖 112
注册 2006-8-28
状态 离线
|
『第 45 楼』:
使用 LLM 解释/回答一下
用下面的代码可以写就一个很好的小型VBS调试器;细节先不关心了,暂时先记录下来。
host =WScript.FullName
hostexe =LCase(Mid(host,InStrRev(host,"\")+1))
If Not hostexe = "cscript.exe" Then
Set wshshell = CreateObject("wscript.shell")
wshshell.Run "cscript.exe"""& WScript.ScriptFullName &""""
WScript.Quit
End If
Set input =WScript.StdIn
Set output =WScript.StdOut
output.Write "> "
Do Until input.AtEndOfStream
line =input.ReadLine
If LCase(line)="exit" Then
Exit Do
Else
line = Replace(line,"?","output.writeline")
executeit line
output.Write "> "
End If
Loop
Sub executeit(command)
On Error Resume Next
ExecuteGlobal command
If Not Err.Number=0 Then
output.WriteLine "error: " & Err.Description
Err.Clear
End If
End sub
Last edited by Billunique on 2007-6-14 at 10:50 AM ]
The following code can be used to write a very good small VBS debugger; details don't need to be cared about for the time being, just record it for now.
host = WScript.FullName
hostexe = LCase(Mid(host, InStrRev(host, "\") + 1))
If Not hostexe = "cscript.exe" Then
Set wshshell = CreateObject("wscript.shell")
wshshell.Run "cscript.exe""" & WScript.ScriptFullName & """"
WScript.Quit
End If
Set input = WScript.StdIn
Set output = WScript.StdOut
output.Write "> "
Do Until input.AtEndOfStream
line = input.ReadLine
If LCase(line) = "exit" Then
Exit Do
Else
line = Replace(line, "?", "output.writeline")
executeit line
output.Write "> "
End If
Loop
Sub executeit(command)
On Error Resume Next
ExecuteGlobal command
If Not Err.Number = 0 Then
output.WriteLine "error: " & Err.Description
Err.Clear
End If
End sub
Last edited by Billunique on 2007-6-14 at 10:50 AM ]
|

★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲ |
|
2007-6-13 19:24 |
|
|