velociraptor yazdı: ↑09 May 2023, 21:59
mehmet.akif.simsek yazdı: ↑09 May 2023, 21:06
Tek eksiği scripte bir başlık verdirtemedim. İstenilen Boyutta Dosya Oluşturma Aracı yazsın istiyorum bunu beceremedi bunu nasıl yazdırtırım
Aşağıdaki satırda
www. sordum .net yerine başlık için hehangi birşey yazabilirsin
Kod: Tümünü seç
strSize = InputBox("Dosya boyutunu girin (byte cinsinden):","www.sordum.net")
Hocam bir şey daha danışmak istiyorum yukarıdaki çeviriciyi çalıştırdım fakat sonuçları yani kb byte yada mb cinsinin sonucu kopyalanabilir değil message box olarak veriyor bu yapay zekaya kopyalabilir çıktı vermesini istedim 2 farklı kod verdi ikiside çalışmadı bir bakabilir misiniz size zahmet
KOD 1
Kod: Tümünü seç
' Kullanıcıdan giriş al
Dim value, unit
value = InputBox("Değer girin:")
unit = InputBox("Birim girin (gigabyte, megabyte, kilobyte, byte):")
' Dönüşümü yap ve sonuçları oluştur
Dim resultText
resultText = ConvertSize(value, unit)
' Sonuçları mesaj kutusu olarak göster
MsgBox resultText, vbInformation, "Sonuç"
' Sonuçları panoya kopyala
CopyToClipboard resultText
MsgBox "Sonuçlar panoya kopyalandı.", vbInformation, "Bilgi"
' Dönüşüm fonksiyonu
Function ConvertSize(value, unit)
' Girdi birimine göre dönüşüm faktörlerini belirle
Dim gigabyteFactor, megabyteFactor, kilobyteFactor, byteFactor
Select Case LCase(unit)
Case "gigabyte"
gigabyteFactor = 1
megabyteFactor = 1024
kilobyteFactor = 1024 * 1024
byteFactor = 1024 * 1024 * 1024
Case "megabyte"
gigabyteFactor = 1 / 1024
megabyteFactor = 1
kilobyteFactor = 1024
byteFactor = 1024 * 1024
Case "kilobyte"
gigabyteFactor = 1 / (1024 * 1024)
megabyteFactor = 1 / 1024
kilobyteFactor = 1
byteFactor = 1024
Case "byte"
gigabyteFactor = 1 / (1024 * 1024 * 1024)
megabyteFactor = 1 / (1024 * 1024)
kilobyteFactor = 1 / 1024
byteFactor = 1
Case Else
' Hatalı birim girdisi
ConvertSize = "Hatalı birim girdisi!"
Exit Function
End Select
' Dönüşümü yap
Dim gigabyteResult, megabyteResult, kilobyteResult, byteResult
gigabyteResult = value * gigabyteFactor
megabyteResult = value * megabyteFactor
kilobyteResult = value * kilobyteFactor
byteResult = value * byteFactor
' Sonuç metnini oluştur
ConvertSize = value & " " & unit & " = " & gigabyteResult & " gigabyte" & vbCrLf & _
value & " " & unit & " = " & megabyteResult & " megabyte" & vbCrLf & _
value & " " & unit & " = " & kilobyteResult & " kilobyte" & vbCrLf & _
value & " " & unit & " = " & byteResult & " byte"
End Function
' Sonucu panoya kopyalamak için yardımcı fonksiyon
Sub CopyToClipboard(text)
With CreateObject("Scripting.FileSystemObject").CreateTextFile("temp.txt", True)
.WriteLine text
.Close
End With
CreateObject("WScript.Shell").Run "cmd.exe /c clip < temp.txt", 0, True
CreateObject("Scripting.FileSystemObject
KOD 2
Kod: Tümünü seç
' Kullanıcıdan giriş al
Dim value, unit
value = InputBox("Değer girin:")
unit = InputBox("Birim girin (gigabyte, megabyte, kilobyte, byte):")
' Dönüşüm fonksiyonu
Sub ConvertSize(value, unit)
' Girdi birimine göre dönüşüm faktörlerini belirle
Dim gigabyteFactor, megabyteFactor, kilobyteFactor, byteFactor
Select Case LCase(unit)
Case "gigabyte"
gigabyteFactor = 1
megabyteFactor = 1024
kilobyteFactor = 1024 * 1024
byteFactor = 1024 * 1024 * 1024
Case "megabyte"
gigabyteFactor = 1 / 1024
megabyteFactor = 1
kilobyteFactor = 1024
byteFactor = 1024 * 1024
Case "kilobyte"
gigabyteFactor = 1 / (1024 * 1024)
megabyteFactor = 1 / 1024
kilobyteFactor = 1
byteFactor = 1024
Case "byte"
gigabyteFactor = 1 / (1024 * 1024 * 1024)
megabyteFactor = 1 / (1024 * 1024)
kilobyteFactor = 1 / 1024
byteFactor = 1
Case Else
' Hatalı birim girdisi
MsgBox "Hatalı birim girdisi!", vbCritical
Exit Sub
End Select
' Dönüşümü yap
Dim gigabyteResult, megabyteResult, kilobyteResult, byteResult
gigabyteResult = value * gigabyteFactor
megabyteResult = value * megabyteFactor
kilobyteResult = value * kilobyteFactor
byteResult = value * byteFactor
' Sonuçları kopyalayabilir şekilde mesaj kutusunda göster
Dim resultText
resultText = value & " " & unit & " = " & gigabyteResult & " gigabyte" & vbCrLf & _
value & " " & unit & " = " & megabyteResult & " megabyte" & vbCrLf & _
value & " " & unit & " = " & kilobyteResult & " kilobyte" & vbCrLf & _
value & " " & unit & " = " & byteResult & " byte"
MsgBox resultText, vbInformation, "Sonuç"
' Sonuçları panoya kopyala
CreateObject("WScript.Shell").Run "cmd.exe /c echo " & resultText & " | clip", 0, True
MsgBox "Sonuçlar panoya kopyalandı.", vbInformation, "Bilgi"
End Sub
' Dönüşümü yap
ConvertSize value, unit