| خانه | آرشیو | پست الکترونیک |
|
تمرین IF
تمرین IF : ماکرویی طراحی کنید که نمره ی دانش آموزی را از کاربر گرفته اگر
0=<نمره =<7 ضعیف 7<نمره =<14 متوسط 14<نمره =<20 خوب پیام های مقابل آنها را چاپ نماید . Sub NOMREH() Dim NOM As Single NOM = InputBox(" نمره را وارد کنید") If NOM >= 0 And NOM <= 7 Then MsgBox "BAD" If NOM > 7 And NOM <= 14 Then MsgBox " NOT BAD" If NOM > 14 And NOM <= 20 Then MsgBox "GOOD" End Sub به این نکته توجه داشته باشید که اگر فرامین IF فقط یک دستور باشند دیگر نیازی به END IF نیست البته دستور مورد نظر را باید در پشت سر THEN نوشت . |+| نوشته شده توسط علی توضیح در سه شنبه نوزدهم تیر 1386 و ساعت 9:53 |
راهنمای استفاده از دستور شرطی IF
If...Then...Else Statement*برگرفته از راهنمای اکسل* Conditionally executes a group of statements, depending on the value of an expression. Syntax If condition Then [statements] [Else elsestatements] Or, you can use the block form syntax: If condition Then [ElseIf condition-n Then [Else End If The If...Then...Else statement syntax has these parts:
Remarks You can use the single-line form (first syntax) for short, simple tests. However, the block form (second syntax) provides more structure and flexibility than the single-line form and is usually easier to read, maintain, and debug. Note With the single-line form, it is possible to have multiple statements executed as the result of an If...Then decision. All statements must be on the same line and separated by colons, as in the following statement:
A block form If statement must be the first statement on a line. The Else, ElseIf, and End If parts of the statement can have only a line number or line label preceding them. The block If must end with an End If statement. To determine whether or not a statement is a block If, examine what follows the Then keyword. If anything other than a comment appears after Then on the same line, the statement is treated as a single-line If statement. The Else and ElseIf clauses are both optional. You can have as many ElseIf clauses as you want in a block If, but none can appear after an Else clause. Block If statements can be nested; that is, contained within one another. When executing a block If (second syntax), condition is tested. If condition is True, the statements following Then are executed. If condition is False, each ElseIf condition (if any) is evaluated in turn. When a True condition is found, the statements immediately following the associated Then are executed. If none of the ElseIf conditions are True (or if there are no ElseIf clauses), the statements following Else are executed. After executing the statements following Then or Else, execution continues with the statement following End If. Tip Select Case may be more useful when evaluating a single expression that has several possible actions. However, the TypeOf objectname Is objecttype clause can't be used with the Select Case statement. Note TypeOf cannot be used with hard data types such as Long, Integer, and so forth other than Object. |+| نوشته شده توسط علی توضیح در سه شنبه نوزدهم تیر 1386 و ساعت 9:41 |
شرط ها و ساختار های تصمیم گیری در وی بی ای IF IN VBA
یکی از مهمترین بخش های هر زبان برنامه نویسی ساختار های تصمیمگیری در آنهاست .
IF یکی از پرکاربرد ترین دستورات VBA می باشد ، ساختار آن عبارت است از : IF شرط THEN عملیات مورد نظر END IF مثال : می خواهیم ساختار شرطی ایجاد کنیم که اگر محتویات سلول A1 از عدد 10 کوچکتر بود یک پیام مردودی نمایش دهد . ( فقط ساختار IF را نمایش می دهیم ) IF RANGE("A1")<10 THEN MSGBOX" مردود" END IF |+| نوشته شده توسط علی توضیح در سه شنبه نوزدهم تیر 1386 و ساعت 9:30 |
تمرین 2
تمرین 2 - ماکرویی طراحی کنید که نام و نام خانوادگی را از کاربر دریافت کرده سپس آنها را در کنار یکدیگر نمایش دهد .
SUB NAM() DIM N AS STRING DIM F AS STRING N= INPUTBOX("ENTER NAME :") F=INPUTBOX("ENTER FAMILY :") MSGBOX N&" "&F END SUB |+| نوشته شده توسط علی توضیح در سه شنبه نوزدهم تیر 1386 و ساعت 9:15 |
تمرین
تمرین : ماکرویی بنویسید که دو عدد را از کاربر گرفته و سپس ضرب آنها را نمایش دهد :
SUB ZARB() DIM I AS SINGLE DIM J AS SINGLE DIM K AS SINGLE I= INPUTBOX(" ENTER I :") J= INPUTBOX(" ENTER J :") K=I*J MSGBOX " I*J = " &K END SUB |+| نوشته شده توسط علی توضیح در سه شنبه نوزدهم تیر 1386 و ساعت 9:9 |
معرفی متغیر ها در وی بی ای
برای استفاده از متغیر ها در وی بی ای VBA بهتر است که آنها را تعریف کنیم ، دو نوع متغیر عددی و غیر عددی وجود دارد که عددی ها عبارتند از :
و غیر عددی عا عبارتند از:
روش معرفی متغیر ها استفاده از کلمه ی کلیدی DIM بعد از نام ماکروست . به مثال زیر توجه کنید: I به عنوان یک عدد صحیح ( متغیر) معرفی شده است . SUB ALI() DIM I AS INTEGER ' I به عنوان یک عدد صحیح معرفی I = INPUTBOX (" ENTER A NUMBER INTEGER:") END SUB
Data Type Summary
The following table shows the supported data types, including storage sizes and ranges.
Note Arrays of any data type require 20 bytes of memory plus 4 bytes for each array dimension plus the number of bytes occupied by the data itself. The memory occupied by the data can be calculated by multiplying the number of data elements by the size of each element. For example, the data in a single-dimension array consisting of 4 Integer data elements of 2 bytes each occupies 8 bytes. The 8 bytes required for the data plus the 24 bytes of overhead brings the total memory requirement for the array to 32 bytes. A Variant containing an array requires 12 bytes more than the array alone. Note Use the StrConv function to convert one type of string data to another.
|+| نوشته شده توسط علی توضیح در سه شنبه پنجم تیر 1386 و ساعت 13:16 |
INPUTBOX جعبه دریافت داده
هر گاه کاربر قصد دریافت داده ها را از کاربرگ نداشته باشد و بخواهد آنها را مستقیما دریافت کند از این ابزار استفاده می کند :
Sub ALI() در مثال فوق ماکرو ساده ای را مشاهده می کنید که پیام " عدد مورد نظر را وارد کنید " را نمایش داده و عدد یا متن کاربر را دریافت کرده و در متغییر I می ریزد . شکل این تابع به صورت زیر است : InputBox Function
Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns a String containing the contents of the text box. Syntax InputBox(prompt[, title] [, default] [, xpos] [, ypos] [, helpfile, context]) The InputBox function syntax has these named arguments:
Remarks When both helpfile and context are provided, the user can press F1 (Windows) or HELP (Macintosh) to view the Help topic corresponding to the context. Some host applications, for example, Microsoft Excel, also automatically add a Help button to the dialog box. If the user clicks OK or presses ENTER , the InputBox function returns whatever is in the text box. If the user clicks Cancel, the function returns a zero-length string (""). Note To specify more than the first named argument, you must use InputBox in an expression. To omit some positional arguments, you must include the corresponding comma delimiter.
مثال :
Sub proInput() J = InputBox("For what year do you need this report?") End Sub
|+| نوشته شده توسط علی توضیح در سه شنبه پنجم تیر 1386 و ساعت 10:3 |
دانلود تمرین وی بی for & if
برای دانلود ابتدا تمرین را دانلود کرده و سپس سعی کنید آنرا بدون ااستفاده از راهنما حل کنید: صورت مسله : ماکرویی بنویسید که اعداد ستون اول را در در ستون دوم جستجو کرده و تکراری های آنرا یافته با رنگ سرخ و پررنگ نمایش دهد .
|+| نوشته شده توسط علی توضیح در دوشنبه چهارم تیر 1386 و ساعت 14:6 |
|
درباره وبلاگ
![]() بنام خدا
این وبلاگ آموزشی سعی دارد با ایجاد یک کلاس آموزشی مجازی و تعاملی در حد امکان به نیاز های روزمره کاربران نرم افزار صفحه گسترده اکسل اعم از شناخت محیط ،قالب بندی ها ،ترسیم جداول ، رنگها ، شرطها ، محاسبات ، فرمول نویسی ، استفاده از توابع ، نمودار ها ، چاپ ، تحلیل داده ها توابع آرایه ای فیلتر سازی و جداول محوری و ماکرو نوسی ... منوی اصلی
صفحه نخستپست الكترونيك آرشيو مطالب خانگي سازی ذخيره كردن صفحه اضافه به علاقه منديها نوشته های پیشین
آبان 1388اسفند 1387 دی 1387 آذر 1387 مهر 1387 تیر 1387 اردیبهشت 1387 فروردین 1387 اسفند 1386 بهمن 1386 شهریور 1386 مرداد 1386 تیر 1386 خرداد 1386 اردیبهشت 1386 فروردین 1386 اسفند 1385 بهمن 1385 شهریور 1385 مرداد 1385 تیر 1385 خرداد 1385 اردیبهشت 1385 فروردین 1385 اسفند 1384 بهمن 1384 دی 1384 آذر 1384 آرشيو موضوعی
توابعنمودارها آشنایی با محیط اکسل جداول محوری توابع گزارش گیری فرمول ها و توابع آرایه ای مطالب گوناگون فرم سازی آمار VBA معتبر سازي داده ها VALIDATION ابزارهاي اكسل پيوندها
آمار 80 آموزش مقدماتی اکسل ماکس ایران آموزش گام به گام اکسل آموزش اکسل 2000 آموزش تصویری اکسل تکنولوژی های آموزشی سایت های آموزش کامپیوتر معرفی کتب کامپیوتر آموزش icdl قوه قضاییه آموزش منوهای اکسل یک وبلاگ بسیار زیبا پژوهش های آماری تاریخ شمسی با اکسل ترفند های ویندوز - وبلاگی زیبا پایگاه کتب الکترونیکی تخصصی آموزش طراحی صفحات وب سایت cpearson contextures EXCEL HOME PAGE آموزش spss یک وبلاگ جالب نكات آفيس آموزش جامع حسابداري ( جالب) قالب های حرفه ای وبلاگ ابزار وب فارسی امکانات
|
| Powered By Blogfa - Designing & Supporting Tools By WebGozar |