Autor Beitrag
BadAzz
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Sa 01.10.05 09:49 
Kann man so ein Programm erstellen, wo man z.B. byetes eingeben kann und der rechnet das in MB um? OK kann man villt auch im kopf aber wie steht es denn mit MB->GB KB->GB usw...???
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 01.10.05 09:55 
Das Dürfte doch nicht das Problem sein
1b = 8B
1kb = 1,024 b
1mb = 1,024 kb
1gb = 1,024 mb
1tb = 1,024 gb
starsurfer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Sa 01.10.05 09:57 
1 KByte = 1024 Byte
1 MByte = 1024 KByte
1 GByte = 1024 MByte
1 TByte = 1024 GByte

8 Bit = 1Byte

arr zu langsam :wink:
so da machst du halt ne berechnungsformel draus

_________________
GEIZ IST GEIL! - Ihr Sozialamt
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Sa 01.10.05 10:12 
user profile iconBlackheart666 hat folgendes geschrieben:
Das Dürfte doch nicht das Problem sein

Sorry, das ist leider doch ein Problem. Guggst du hier.
BadAzz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Sa 01.10.05 10:12 
SORRY bin GANZ neu in sachen delphi haben das erst 1mal inna schule gehabt. wie mach ich denn sone formel
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Sa 01.10.05 10:14 
user profile iconBlackheart666 hat folgendes geschrieben:
Das Dürfte doch nicht das Problem sein
1b = 8B
1kb = 1,024 b
1mb = 1,024 kb
1gb = 1,024 mb
1tb = 1,024 gb


Mhm, ich glaube du meinst das richtig, hast aber das falsche hingeschrieben ;). Denn ein Bit sind nicht 8 Byte usw. ;).

Und bei starsurfer Aufzählung fehlt 1B=8b (B=Byte; b=Bit), was du aber normalerweide nicht brauchst ;)
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Sa 01.10.05 10:17 
user profile iconBadAzz hat folgendes geschrieben:
SORRY bin GANZ neu in sachen delphi haben das erst 1mal inna schule gehabt. wie mach ich denn sone formel


Brauchst du es nur zum Umrechnen, oder gleich um die Größe von Dateien zu bestimmen?

Für das zweite hier ein Quelltext:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
function GetFileSize(const FileName: String): String;
var
  hFile: THandle;
  Data: WIN32_FIND_DATA;
  Size: LARGE_INTEGER;
  Groesse: Int64;
begin
  Groesse:=0;
  hFile:=FindFirstFile(PChar(FileName), Data);
  try
    if hFile<>INVALID_HANDLE_VALUE then
    begin
      Size.LowPart:=Data.nFileSizeLow;
      Size.HighPart:=Data.nFileSizeHigh;
      Groesse:=Size.QuadPart;
    end
  finally
    Windows.FindClose(hFile);
  end;
  if Groesse>1023 then //KB
  begin
    if Groesse>1048575 then //MB
    begin
      if Groesse>1073741823 then //MB
      begin
        Result:=Format('%.2f GB', [Groesse/1073741824])
      end
      else
      begin
        Result:=Format('%.2f MB', [Groesse/1048576])
      end
    end
    else
    begin
      Result:=Format('%.2f KB', [Groesse/1024])
    end
  end
  else
  begin
    Result:=IntToStr(Groesse)+' Bytes'
  end
end;


Und für den ersten Fall brauchst nur den Quelltext anpassen, in dem du ihm die Größe übergibst ;).
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Sa 01.10.05 10:18 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
Function Bytes2MBytesBasis2(Bytes : LongInt) : Double;
begin
  result := Bytes / 1024 / 1024; // Einmal für kByte und einmal für mByte
end;

Die Funktion musst du noch in deinem Programm einbauen und aufrufen.

Zu der Funktions-Bezeichnung (Basis2) siehe auch meinen Link weiter oben.
BadAzz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Sa 01.10.05 10:21 
Sorry das ist mir jetzt echt peinlich aber:
:oops: Wo muss das hin und muss ich noch buttons oder so machen?
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Sa 01.10.05 10:26 
user profile iconBadAzz hat folgendes geschrieben:
Sorry das ist mir jetzt echt peinlich aber:
:oops: Wo muss das hin und muss ich noch buttons oder so machen?

Das muss dir nicht peinlich sein. Allerdings ist es müßig das zu erklären. Entweder macht dir das einer mal eben fertig (so viel ist es nicht) oder du nimmst dir mal das hier vor. Beim zweiten Weg lernst du auch noch gleichzeitig eine ganze Menge und sparst dir eine Menge Fragen.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Sa 01.10.05 10:26 
Je nachdem wo du es Aufrufen möchtest.

Für meine Variante z.B. bei einem Button-Ereignis:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm.Button1Click(Sender: TObject);
begin
  ShowMessage('Die Größe der Datei beträgt '+GetFileSize(test.bmp)); 
end;


Bei jasocul:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm.Button1Click(Sender: TObject);
begin
  ShowMessage('Die Größe der Datei beträgt '+FloatToStr(Bytes2MBytesBasis2(1256341531))+' MB'); 
end;
BadAzz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Sa 01.10.05 10:34 
Ich bin sooooo ein nooob
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Sa 01.10.05 10:38 
Wenndu sagast was du nicht verstehst können wir die auch weiterhelfen. Aber am besten wäre es, wenn du dir ein paar Tut's durchlesen würdest, was vermutlich effektiver wäre als wenn wir es versuchen dir zu erklären ;).
BadAzz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Sa 01.10.05 10:39 
ok ich fang dann mal mit nem tut an und wenn ich dann noch fragen hab dann kann ich ja fragen, oder?
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Sa 01.10.05 10:42 
Selbstverständlich.
caedes
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 35

Win XP
Delphi 7 Enterprise, C
BeitragVerfasst: Sa 01.10.05 10:54 
user profile iconBadAzz hat folgendes geschrieben:
Ich bin sooooo ein nooob

Wenn du in deinen Delphi-Kenntnissen etwas vorangeschritten bist, kannst du ja mal versuchen, das angehängte Projekt nachzuvollziehen. Ich vermute dein größtes Problem ist vielmehr die Umsetzung in Delphi.

Viel Erfolg noch...
Einloggen, um Attachments anzusehen!
BadAzz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Sa 01.10.05 11:47 
user profile iconcaedes hat folgendes geschrieben:
user profile iconBadAzz hat folgendes geschrieben:
Ich bin sooooo ein nooob

Wenn du in deinen Delphi-Kenntnissen etwas vorangeschritten bist, kannst du ja mal versuchen, das angehängte Projekt nachzuvollziehen. Ich vermute dein größtes Problem ist vielmehr die Umsetzung in Delphi.

Viel Erfolg noch...



HEY Vielen dank!
Dr. Chaotica
Hält's aus hier
Beiträge: 5

XP
Delphi 7, PHP 5
BeitragVerfasst: Do 06.10.05 09:30 
Hey caedes. Dein Programm kann einen Terabyte nicht in Bytes anzeigen *g*
Also ehrlich... Ich bin da etwas mehr von dir gewohnt.
Apropos. Wie siehts mit Logline aus? Oder mit dem Touchscreen-Projekt. Womma irgendwann weitermachen?
Wann sind deine Klausuren vorbei?

MfG Dr. Chaotica

_________________
Gott?
Ich bin dagegen!