تقييم الموضوع :
  • 1 أصوات - بمعدل 3
  • 1
  • 2
  • 3
  • 4
  • 5
الفرق بين اكواد ال vb6 و Java
#1
كاتب الموضوع : كان+فعل=ماضي

السلام عليكم و رحمة الله و بركاته
***********************
***
VB6

كود :
[color=#000000][COLOR=#0000bb]Dim d [/color][color=#007700]As [/color][color=#0000bb]Double [/color][COLOR=#dd0000]' A double can hold decimal places
Dim i As Integer ' [/COLOR][COLOR=#0000bb]An integer can hold integers
Dim s [/COLOR][color=#007700]As [/color][COLOR=#0000bb]String  A string can hold characters

d [/COLOR][color=#007700]= [/color][COLOR=#0000bb]3.14
i [/COLOR][color=#007700]= [/color][COLOR=#0000bb]10
s [/COLOR][color=#007700]= [/color][COLOR=#dd0000]"Visual Basic"  
[/COLOR][color=#0000bb][/color][/COLOR]

Java

كود :
[color=#000000][COLOR=#0000bb]int i[/color][color=#007700];[/color][COLOR=#ff8000]// ints can store integer numbers
[/COLOR][color=#0000bb]double d[/color][color=#007700];[/color][COLOR=#ff8000]// doubles can have decimal places
[/COLOR][color=#0000bb]String s[/color][color=#007700];[/color][COLOR=#ff8000]// strings can hold characters

[/COLOR][color=#0000bb]i [/color][color=#007700]= [/color][color=#0000bb]10[/color][COLOR=#007700];
[/COLOR][color=#0000bb]d [/color][color=#007700]= [/color][color=#0000bb]3.14[/color][COLOR=#007700];
[/COLOR][color=#0000bb]s [/color][color=#007700]= [/color][color=#dd0000]"Java"[/color][COLOR=#007700];  
[/COLOR][color=#0000bb][/color][/COLOR]

**********
vb6

كود :
[color=#000000][COLOR=#0000bb]Dim a [/color][color=#007700]as [/color][COLOR=#0000bb]integer
Dim b [/COLOR][color=#007700]as [/color][COLOR=#0000bb]integer

a[/COLOR][color=#007700]=[/color][COLOR=#0000bb]1
b[/COLOR][color=#007700]=[/color][COLOR=#0000bb]2

[/COLOR][color=#007700]if [/color][color=#0000bb]a[/color][color=#007700]=[/color][COLOR=#0000bb]b then
    MsgBox [/COLOR][COLOR=#dd0000]"A and B are equal"
[/COLOR][COLOR=#007700]else
    [/COLOR][color=#0000bb]MsgBox [/color][COLOR=#dd0000]"A and B are not equal"
[/COLOR][color=#0000bb]end [/color][COLOR=#007700]if  
[/COLOR][color=#0000bb][/color][/COLOR]

java

كود :
[color=#000000][COLOR=#0000bb]int a[/color][color=#007700],[/color][color=#0000bb]b[/color][COLOR=#007700];

[/COLOR][color=#0000bb]a[/color][color=#007700]=[/color][color=#0000bb]1[/color][COLOR=#007700];
[/COLOR][color=#0000bb]b[/color][color=#007700]=[/color][color=#0000bb]2[/color][COLOR=#007700];

if([/COLOR][color=#0000bb]a[/color][color=#007700]==[/color][color=#0000bb]b[/color][COLOR=#007700])
{
    [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"A and B are equal"[/color][COLOR=#007700]);
}
else
{
    [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"A and B are not equal"[/color][COLOR=#007700]);
}  
[/COLOR][color=#0000bb][/color][/COLOR]

****************
vb6

كود :
[color=#000000][COLOR=#0000bb]Dim a [/color][color=#007700]As [/color][COLOR=#0000bb]Integer
Dim b [/COLOR][color=#007700]As [/color][COLOR=#0000bb]Integer

a [/COLOR][color=#007700]= [/color][COLOR=#0000bb]1
b [/COLOR][color=#007700]= [/color][COLOR=#0000bb]2

[/COLOR][color=#007700]If ([/color][color=#0000bb]a [/color][color=#007700]= [/color][color=#0000bb]b[/color][color=#007700]) Or ([/color][color=#0000bb]a [/color][color=#007700]= [/color][color=#0000bb]2[/color][color=#007700]) [/color][COLOR=#0000bb]Then
    MsgBox [/COLOR][COLOR=#dd0000]"A and B are equal, or a equals 2"
[/COLOR][COLOR=#007700]Else
    [/COLOR][color=#0000bb]MsgBox [/color][COLOR=#dd0000]"A and B are not equal or a is not 2"
[/COLOR][color=#0000bb]End [/color][COLOR=#007700]If

If ([/COLOR][color=#0000bb]a [/color][color=#007700]= [/color][color=#0000bb]b[/color][color=#007700]) And ([/color][color=#0000bb]a [/color][color=#007700]= [/color][color=#0000bb]2[/color][color=#007700]) [/color][COLOR=#0000bb]Then
    MsgBox [/COLOR][COLOR=#dd0000]"A and B are equal, and a equals 2"
[/COLOR][COLOR=#007700]Else
    [/COLOR][color=#0000bb]MsgBox [/color][COLOR=#dd0000]"A and B are not 2"
[/COLOR][color=#0000bb]End [/color][COLOR=#007700]If  
[/COLOR][color=#0000bb][/color][/COLOR]

java

كود :
[color=#000000][COLOR=#0000bb]int a[/color][color=#007700],[/color][color=#0000bb]b[/color][COLOR=#007700];

[/COLOR][color=#0000bb]a[/color][color=#007700]=[/color][color=#0000bb]1[/color][COLOR=#007700];
[/COLOR][color=#0000bb]b[/color][color=#007700]=[/color][color=#0000bb]2[/color][COLOR=#007700];

if( ([/COLOR][color=#0000bb]a[/color][color=#007700]==[/color][color=#0000bb]b[/color][color=#007700]) || ([/color][color=#0000bb]a[/color][color=#007700]==[/color][color=#0000bb]2[/color][COLOR=#007700]) )
{
    [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"A and B are equal, or a equals 2"[/color][COLOR=#007700]);
}
else
{
    [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"A and B are not equal or a is not 2"[/color][COLOR=#007700]);
}

if( ([/COLOR][color=#0000bb]a[/color][color=#007700]==[/color][color=#0000bb]b[/color][color=#007700]) && ([/color][color=#0000bb]a[/color][color=#007700]==[/color][color=#0000bb]2[/color][COLOR=#007700]) )
{
    [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"A and B are equal, and a equals 2"[/color][COLOR=#007700]);
}
else
{
    [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"A and B are not 2"[/color][COLOR=#007700]);
}  
[/COLOR][color=#0000bb][/color][/COLOR]

**********
vb6

كود :
[color=#000000][COLOR=#0000bb]Dim a [/color][color=#007700]As [/color][COLOR=#0000bb]Integer


a [/COLOR][color=#007700]= [/color][COLOR=#0000bb]1

[/COLOR][color=#007700]While ([/color][color=#0000bb]a [/color][color=#007700]<= [/color][color=#0000bb]10[/color][COLOR=#007700])
    [/COLOR][color=#0000bb]MsgBox [/color][color=#dd0000]"Counting: " [/color][color=#007700]& [/color][color=#0000bb]a [/color][color=#007700]& [/color][COLOR=#dd0000]"..."
    [/COLOR][color=#0000bb]a [/color][color=#007700]= [/color][color=#0000bb]a [/color][color=#007700]+ [/color][color=#0000bb]1  could also [/color][color=#007700]use [/color][color=#0000bb]the shorthand a[/color][COLOR=#007700]++;
[/COLOR][COLOR=#0000bb]Wend  
[/COLOR][/COLOR]

java

كود :
[color=#000000][COLOR=#0000bb]int a[/color][COLOR=#007700];

[/COLOR][color=#0000bb]a[/color][color=#007700]=[/color][color=#0000bb]1[/color][COLOR=#007700];

while( [/COLOR][color=#0000bb]a[/color][color=#007700]<=[/color][color=#0000bb]10 [/color][COLOR=#007700])
{
    [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"Counting: " [/color][color=#007700]+ [/color][color=#0000bb]a [/color][color=#007700]+ [/color][color=#dd0000]"..." [/color][COLOR=#007700]);
    [/COLOR][color=#0000bb]a [/color][color=#007700]= [/color][color=#0000bb]a [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700];[/color][COLOR=#ff8000]// could also use the shorthand a++;
[/COLOR][COLOR=#007700]}  
[/COLOR][color=#0000bb][/color][/COLOR]

*******
vb6

كود :
[color=#000000][COLOR=#0000bb]a [/color][color=#007700]= [/color][COLOR=#0000bb]1

[/COLOR][COLOR=#007700]Do
    [/COLOR][color=#0000bb]MsgBox [/color][color=#dd0000]"Counting: " [/color][color=#007700]& [/color][color=#0000bb]a [/color][color=#007700]& [/color][COLOR=#dd0000]"..."
    [/COLOR][color=#0000bb]a [/color][color=#007700]= [/color][color=#0000bb]a [/color][color=#007700]+ [/color][color=#0000bb]1  could also [/color][color=#007700]use [/color][color=#0000bb]the shorthand a[/color][COLOR=#007700]++;
[/COLOR][color=#0000bb]Loop [/color][color=#007700]While ([/color][color=#0000bb]a [/color][color=#007700]<= [/color][color=#0000bb]10[/color][COLOR=#007700])  
[/COLOR][color=#0000bb][/color][/COLOR]

java

كود :
[color=#000000][COLOR=#0000bb]int a[/color][COLOR=#007700];

[/COLOR][color=#0000bb]a[/color][color=#007700]=[/color][color=#0000bb]1[/color][COLOR=#007700];

do
{
    [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"Counting: " [/color][color=#007700]+ [/color][color=#0000bb]a [/color][color=#007700]+ [/color][color=#dd0000]"..." [/color][COLOR=#007700]);
    [/COLOR][color=#0000bb]a [/color][color=#007700]= [/color][color=#0000bb]a [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700];[/color][COLOR=#ff8000]// could also use the shorthand a++;
[/COLOR][color=#007700]} while( [/color][color=#0000bb]a[/color][color=#007700]<=[/color][color=#0000bb]10 [/color][COLOR=#007700]);  
[/COLOR][color=#0000bb][/color][/COLOR]

*****
vb6

كود :
[color=#000000][COLOR=#0000bb]a [/color][color=#007700]= [/color][COLOR=#0000bb]1

Dim a [/COLOR][color=#007700]As [/color][COLOR=#0000bb]Integer

[/COLOR][COLOR=#dd0000]' count from 1 to 10

For a = 1 To 10
    MsgBox "Counting:" & a & "..."
Next a

' [/COLOR][COLOR=#0000bb]count from 10 to 1

[/COLOR][color=#007700]For [/color][color=#0000bb]a [/color][color=#007700]= [/color][color=#0000bb]10 To 1 Step [/color][color=#007700]-[/color][COLOR=#0000bb]1
    MsgBox [/COLOR][color=#dd0000]"Counting:" [/color][color=#007700]& [/color][color=#0000bb]a [/color][color=#007700]& [/color][COLOR=#dd0000]"..."
[/COLOR][COLOR=#0000bb]Next a

count from 2 to 10 by twos

[/COLOR][color=#007700]For [/color][color=#0000bb]a [/color][color=#007700]= [/color][COLOR=#0000bb]2 To 10 Step 2
    MsgBox [/COLOR][color=#dd0000]"Counting:" [/color][color=#007700]& [/color][color=#0000bb]a [/color][color=#007700]& [/color][COLOR=#dd0000]"..."
[/COLOR][COLOR=#0000bb]Next a  
[/COLOR][/COLOR]

java

كود :
[COLOR=#000000][COLOR=#0000bb]
int a[/COLOR][COLOR=#007700];

[/COLOR][COLOR=#ff8000]// count from 1 to 10

[/COLOR][color=#007700]for([/color][color=#0000bb]a[/color][color=#007700]=[/color][color=#0000bb]1[/color][color=#007700];[/color][color=#0000bb]a[/color][color=#007700]<=[/color][color=#0000bb]10[/color][color=#007700];[/color][color=#0000bb]a[/color][COLOR=#007700]++)
{
    [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"Counting: " [/color][color=#007700]+ [/color][color=#0000bb]a [/color][color=#007700]+ [/color][color=#dd0000]"..." [/color][COLOR=#007700]);
}

[/COLOR][COLOR=#ff8000]// count from 10 to 1

[/COLOR][color=#007700]for([/color][color=#0000bb]a[/color][color=#007700]=[/color][color=#0000bb]10[/color][color=#007700];[/color][color=#0000bb]a[/color][color=#007700]>=[/color][color=#0000bb]1[/color][color=#007700];[/color][color=#0000bb]a[/color][COLOR=#007700]--)
{
    [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"Counting: " [/color][color=#007700]+ [/color][color=#0000bb]a [/color][color=#007700]+ [/color][color=#dd0000]"..." [/color][COLOR=#007700]);
}

[/COLOR][COLOR=#ff8000]// count from 2 to 10 by twos

[/COLOR][color=#007700]for([/color][color=#0000bb]a[/color][color=#007700]=[/color][color=#0000bb]2[/color][color=#007700];[/color][color=#0000bb]a[/color][color=#007700]<=[/color][color=#0000bb]10[/color][color=#007700];[/color][color=#0000bb]a[/color][color=#007700]+=[/color][color=#0000bb]2[/color][COLOR=#007700])
{
    [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"Counting: " [/color][color=#007700]+ [/color][color=#0000bb]a [/color][color=#007700]+ [/color][color=#dd0000]"..." [/color][COLOR=#007700]);
}  
[/COLOR][color=#0000bb][/color][/COLOR]

*******
vb6

كود :
[color=#000000][COLOR=#0000bb][/color][color=#007700]Private [/color][color=#0000bb]Sub Form_Load[/color][COLOR=#007700]()

[/COLOR][color=#0000bb]Sub ExampleSub[/color][COLOR=#007700]()
    [/COLOR][color=#0000bb]MsgBox [/color][COLOR=#dd0000]"Calling the sub"
[/COLOR][COLOR=#0000bb]End Sub

Sub ExampleFunction[/COLOR][COLOR=#007700]()
    [/COLOR][color=#0000bb]MsgBox [/color][COLOR=#dd0000]"Calling the function"
[/COLOR][COLOR=#0000bb]End Sub

[/COLOR][color=#007700]Function [/color][color=#0000bb]AddIt[/color][color=#007700]([/color][color=#0000bb]x [/color][color=#007700]As [/color][color=#0000bb]Integer[/color][color=#007700], [/color][color=#0000bb]y [/color][color=#007700]As [/color][color=#0000bb]Integer[/color][color=#007700]) As [/color][COLOR=#0000bb]Integer
    Dim result [/COLOR][color=#007700]As [/color][COLOR=#0000bb]Integer

    MsgBox [/COLOR][COLOR=#dd0000]"Calling AddIt"
    [/COLOR][color=#0000bb]result [/color][color=#007700]= [/color][color=#0000bb]x [/color][color=#007700]+ [/color][COLOR=#0000bb]y
    AddIt [/COLOR][color=#007700]= [/color][COLOR=#0000bb]result
End [/COLOR][COLOR=#007700]Function

[/COLOR][color=#0000bb]Sub main[/color][COLOR=#007700]()
    [/COLOR][COLOR=#0000bb]ExampleSub
    ExampleFunction
    Dim t [/COLOR][color=#007700]As [/color][COLOR=#0000bb]Integer
    t [/COLOR][color=#007700]= [/color][color=#0000bb]AddIt[/color][color=#007700]([/color][color=#0000bb]4[/color][color=#007700], [/color][color=#0000bb]3[/color][COLOR=#007700])
    [/COLOR][color=#0000bb]MsgBox [/color][color=#dd0000]"Output: " [/color][color=#007700]& [/color][COLOR=#0000bb]t
End Sub  
[/COLOR][/COLOR]

java

كود :
[color=#000000][COLOR=#0000bb][/color][color=#007700]class [/color][COLOR=#0000bb]HelloWorld
[/COLOR][COLOR=#007700]{
    public static [/COLOR][color=#0000bb]void ExampleSub[/color][COLOR=#007700]()
    {
        [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"Calling the sub"[/color][COLOR=#007700]);
    }

    public static [/COLOR][color=#0000bb]int ExampleFunction[/color][COLOR=#007700]()
    {
        [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"Calling the function"[/color][COLOR=#007700]);
        return [/COLOR][color=#0000bb]5[/color][COLOR=#007700];
    }

    public static [/COLOR][color=#0000bb]int AddIt[/color][color=#007700]([/color][color=#0000bb]int x[/color][color=#007700],[/color][color=#0000bb]int y[/color][COLOR=#007700])
    {
        [/COLOR][color=#0000bb]int result[/color][COLOR=#007700];

        [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"Calling AddIt"[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]result [/color][color=#007700]= [/color][color=#0000bb]x [/color][color=#007700]+ [/color][color=#0000bb]y[/color][COLOR=#007700];

        return [/COLOR][color=#0000bb]result[/color][COLOR=#007700];
    }
    public static [/COLOR][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]String args[/color][COLOR=#007700][])
    {
        [/COLOR][color=#0000bb]ExampleSub[/color][COLOR=#007700]();
        [/COLOR][color=#0000bb]ExampleFunction[/color][COLOR=#007700]();
        [/COLOR][color=#0000bb]int t [/color][color=#007700]= [/color][color=#0000bb]AddIt[/color][color=#007700]([/color][color=#0000bb]4[/color][color=#007700],[/color][color=#0000bb]3[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"Output: " [/color][color=#007700]+ [/color][color=#0000bb]t[/color][COLOR=#007700]);
    }
}  
[/COLOR][color=#0000bb][/color][/COLOR]

************************************************** *********
بــــــالــــــــــــــــــتـــــــــــوفـــــــــ ـــــــــــــــــــــــــــــــيـق
}}}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  Java 7: مالجديد الذي تقدمه للمبرمجين أسامة أحمد 1 580 02-06-16, 02:52 PM
آخر رد: CLARO
  هيا بنا نبدأ مع لغة الجافا ... Java أسامة أحمد 2 1,260 02-06-16, 02:51 PM
آخر رد: CLARO
  Java .. نظرة من الداخل RaggiTech 2 956 07-10-12, 11:14 AM
آخر رد: RaggiTech
  ما الفرق بين Java و JavaScript RaggiTech 0 924 07-10-12, 10:50 AM
آخر رد: RaggiTech

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم