|
Thank you Richard and Gerry.
Coding. Capture screen shot to clipboard and paste to RichTextbox inside PrintBuffer
Same coding using VisualBasic 2010 (32Bit) and Visual Studio 2022 (64Bit)
The image on VB 2010 is perfect and size change with the newWidth, newHeight but with VS 2022 the image is about 1/3 size of previous and will not response to change in newWidth, NewHeight.
Dim newWidth,newHeight as integer
newWeight=710: newHeight=430
Clipboard.Clear()
SendKeys.SendWait("%{PRTSC}"): Call TimeDelay(100)
If IsNothing(Clipboard.GetImage) = False Then
Clipboard.SetImage(New Bitmap(Clipboard.GetImage, newWidth, newHeight))
PrintBuffer = DataToPrint + vbCrLf
frmPrint.ShowDialog()
|
|
|
|
|
I have just tried that again and it works exactly correctly, the image is resized to the values you give above. You can test this for yourself by running the ClipBoard code above, and pasting into one of the paint applications to check the new size. The problem you have is most likely to do with your printing code where you are not adjusting the mapping to account for the different point density between screen and printer. I have only ever done this using the Windows GDI library, so am not sure how you manage it in VB.NET. I suggest you open a new question asking for help on that specific subject.
|
|
|
|
|
Thanks again Richard.
The coding works perfect using Visual Basic 2010, size of image change as defined. However when the same coding used on Visual Studio 2022, the image size will not change with setting, about 1/3 the size by comparison. Not sure if it has anything to do with 32-64Bit platform or just another one of those bugs. My opinion is that Visual Studio 2022 is no good, It is operating like a degraded VBasic. I changed from 2010 to 2022 thinking that the 64Bit enviroment will work and run better. Disappointment. Looks like I will stay with the 2010 even though it is 32Bit. Thanks again
|
|
|
|
|
Well, as I have said twice now (and I just checked again), your code works perfectly with Visual Studio 2022. So whatever you are doing, and however you are measuring the image, is not the same as I am. So without more information it is impossible to make a useful suggestion.
And, to be honest, Visual Studio 2022 is one of the best IDE's I have worked with, and definitely better than the Express versions going back to 2005 and before.
|
|
|
|
|
2010 to 2022 is a big leap. The VS 2022 designer looks at the possible screen sizes / resolutions more closely; using them as defaults during the design. (No idea what "phase" you are talking about)
My current "default design surface" is: "13.5 in. Surface Book (3000x2000)" ... for no obvious reason since my monitors are 27 and 45 in; though it doesn't impact the way I actually use what create.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Hello all...im new and im not even a coder. I just do some apps once in a while to keep the head busy and exercise my mind.
im actually trying to make an mp3 tagger. All is good but i cannot tag new files..only pre-tagged files...it says it cannot convert string to byte in the "Track" and "Genre" fields.
This is the class im using
<pre>Imports System.IO
Public Class MP3ID3v1
Public Sub New(Optional ByVal Filename As String = "")
MyBase.New()
If (Filename <> "") Then Me.Filename = Filename
End Sub
#Region " Declarations "
Public Enum Genres As Byte
Blues = 0
ClassicRock = 1
Country = 2
Dance = 3
Disco = 4
Funk = 5
Grunge = 6
HipHop = 7
Jazz = 8
Metal = 9
NewAge = 10
Oldies = 11
Other = 12
Pop = 13
RnB = 14
Rap = 15
Reggae = 16
Rock = 17
Techno = 18
Industrial = 19
Alternative = 20
Ska = 21
DeathMetal = 22
Pranks = 23
Soundtrack = 24
EuroTechno = 25
Ambient = 26
TripHop = 27
Vocal = 28
JazzFunk = 29
Fusion = 30
Trance = 31
Classical = 32
Instrumental = 33
Acid = 34
House = 35
Game = 36
SoundClip = 37
Gospel = 38
Noise = 39
AlternRock = 40
Bass = 41
Soul = 42
Punk = 43
Space = 44
Meditative = 45
InstrumentalPop = 46
InstrumentalRock = 47
Ethnic = 48
Gothic = 49
Darkwave = 50
TechnoIndustrial = 51
Electronic = 52
PopFolk = 53
Eurodance = 54
Dream = 55
SouthernRock = 56
Comedy = 57
Cult = 58
Gangsta = 59
Top40 = 60
ChristianRap = 61
PopFunk = 62
Jungle = 63
NativeAmerican = 64
Cabaret = 65
NewWave = 66
Psychadelic = 67
Rave = 68
Showtunes = 69
Trailer = 70
LoFi = 71
Tribal = 72
AcidPunk = 73
AcidJazz = 74
Polka = 75
Retro = 76
Musical = 77
RocknRoll = 78
HardRock = 79
None = 255
End Enum
Public Enum FrameTypes As Byte
Title = 0
Artist = 1
Album = 2
Year = 3
Track = 4
Comment = 5
Genre = 6
End Enum
#End Region
#Region " Properties "
Private mstrFilename As String
Public Property Filename() As String
Get
Return mstrFilename
End Get
Set(ByVal Value As String)
Dim objFile As File
If (objFile.Exists(Value)) Then
mstrFilename = Value
Refresh()
Else
Throw New System.IO.FileLoadException("The specified file does not exist", Value)
End If
End Set
End Property
Private mblnTagExists As Boolean
Public ReadOnly Property TagExists() As Boolean
Get
Return mblnTagExists
End Get
End Property
Private mobjFrame(7) As Object
Public Property Frame(ByVal FrameType As FrameTypes)
Get
Return mobjFrame(FrameType)
End Get
Set(ByVal Value)
mobjFrame(FrameType) = Value
End Set
End Property
#End Region
#Region " Methods "
Public Sub Refresh()
Dim strTag As New String(" ", 3)
Dim strTitle As New String(" ", 30)
Dim strArtist As New String(" ", 30)
Dim strAlbum As New String(" ", 30)
Dim strYear As New String(" ", 4)
Dim strComment As New String(" ", 28)
Dim bytDummy As Byte
Dim bytTrack As Byte
Dim bytGenre As Byte
Dim intFile As Integer = FreeFile()
FileOpen(intFile, mstrFilename, OpenMode.Binary, OpenAccess.Read, OpenShare.LockWrite)
Dim lngLOF As Long = LOF(intFile)
If (lngLOF > 128) Then
FileGet(intFile, strTag, lngLOF - 127, True)
If (strTag.ToUpper <> "TAG") Then
mblnTagExists = False
mobjFrame(0) = ""
mobjFrame(1) = ""
mobjFrame(2) = ""
mobjFrame(3) = ""
mobjFrame(4) = ""
mobjFrame(5) = ""
mobjFrame(6) = ""
Else
mblnTagExists = True
FileGet(intFile, strTitle)
FileGet(intFile, strArtist)
FileGet(intFile, strAlbum)
FileGet(intFile, strYear)
FileGet(intFile, strComment)
FileGet(intFile, bytDummy)
FileGet(intFile, bytTrack)
FileGet(intFile, bytGenre)
mobjFrame(0) = strTitle
mobjFrame(1) = strArtist
mobjFrame(2) = strAlbum
mobjFrame(3) = strYear
mobjFrame(4) = bytTrack
mobjFrame(5) = strComment
mobjFrame(6) = bytGenre
End If
End If
FileClose(intFile)
End Sub
Public Sub Update()
Dim strTag As New String(" ", 3)
Dim strTitle As New String(" ", 30)
Dim strArtist As New String(" ", 30)
Dim strAlbum As New String(" ", 30)
Dim strYear As New String(" ", 4)
Dim strComment As New String(" ", 28)
Dim bytDummy As Byte
Dim bytTrack As Byte
Dim bytGenre As Byte
Dim intFile As Integer = FreeFile()
FileOpen(intFile, mstrFilename, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.LockWrite)
Dim lngLOF As Long = LOF(intFile)
If (lngLOF > 0) Then
If (lngLOF > 128) Then
FileGet(intFile, strTag, lngLOF - 127)
If (strTag.ToUpper <> "TAG") Then
Seek(intFile, lngLOF)
strTag = "TAG"
FilePut(intFile, strTag)
End If
strTitle = LSet(mobjFrame(0), Len(strTitle))
strArtist = LSet(mobjFrame(1), Len(strArtist))
strAlbum = LSet(mobjFrame(2), Len(strAlbum))
strYear = LSet(mobjFrame(3), Len(strYear))
bytTrack = mobjFrame(4)
strComment = LSet(mobjFrame(5), Len(strComment))
bytGenre = mobjFrame(6)
FilePut(intFile, strTitle)
FilePut(intFile, strArtist)
FilePut(intFile, strAlbum)
FilePut(intFile, strYear)
FilePut(intFile, strComment)
FilePut(intFile, bytDummy)
FilePut(intFile, bytTrack)
FilePut(intFile, bytGenre)
End If
End If
FileClose(intFile)
End Sub
#End Region
End Class
and this is my code:
<pre>Imports System.IO
Imports System.Windows.Forms.VisualStyles.VisualStyleElement
Imports System.Resources.ResXFileRef
Imports System.Text
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
ListBox1.Items.Clear()
Dim fileNames = My.Computer.FileSystem.GetFiles(FolderBrowserDialog1.SelectedPath, FileIO.SearchOption.SearchTopLevelOnly, "*.mp3")
For Each fileName As String In fileNames
Dim result As String = Path.GetFileName(fileName)
ListBox1.Items.Add(result)
Next
End If
ComboBox1.DataSource = System.Enum.GetValues(GetType(MP3ID3v1.Genres))
Label1.Text = "Title :"
Label2.Text = "Artist :"
Label3.Text = "Album :"
Label4.Text = "Year :"
Label5.Text = "Track :"
Label6.Text = "Comment :"
Label7.Text = "Genre : "
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ListBox1.Items.Clear()
If FolderBrowserDialog1.SelectedPath = "" Then
Dim r8 As DialogResult = MessageBox.Show(Me, "You need to load a folder.",
"Load Files", MessageBoxButtons.OK)
Else
Dim fileNames = My.Computer.FileSystem.GetFiles(FolderBrowserDialog1.SelectedPath, FileIO.SearchOption.SearchTopLevelOnly, "*.mp3")
For Each fileName As String In fileNames
Dim result As String = Path.GetFileName(fileName)
ListBox1.Items.Add(result)
Next
End If
ComboBox1.DataSource = System.Enum.GetValues(GetType(MP3ID3v1.Genres))
Label1.Text = "Title :"
Label2.Text = "Artist :"
Label3.Text = "Album :"
Label4.Text = "Year :"
Label5.Text = "Track :"
Label6.Text = "Comment :"
Label7.Text = "Genre : "
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ComboBox1.DataSource = System.Enum.GetValues(GetType(MP3ID3v1.Genres))
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
Dim objMP3V1 As New MP3ID3v1(FolderBrowserDialog1.SelectedPath & "\" & ListBox1.SelectedItem)
If (objMP3V1.TagExists) Then
Label1.Text = "Title : " & (objMP3V1.Frame(MP3ID3v1.FrameTypes.Title))
Label2.Text = "Artist : " & (objMP3V1.Frame(MP3ID3v1.FrameTypes.Artist))
Label3.Text = "Album : " & (objMP3V1.Frame(MP3ID3v1.FrameTypes.Album))
Label4.Text = "Year : " & (objMP3V1.Frame(MP3ID3v1.FrameTypes.Year))
Dim TR = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Track))
Label5.Text = "Track : " & (TR.ToString)
Label6.Text = "Comment : " & (objMP3V1.Frame(MP3ID3v1.FrameTypes.Comment))
Dim GR As MP3ID3v1.Genres = (objMP3V1.Frame(MP3ID3v1.FrameTypes.Genre))
Label7.Text = "Genre : " & (GR.ToString)
Else
Label1.Text = "Title :"
Label2.Text = "Artist :"
Label3.Text = "Album :"
Label4.Text = "Year :"
Label5.Text = "Track :"
Label6.Text = "Comment :"
Label7.Text = "Genre : "
ComboBox1.DataSource = System.Enum.GetValues(GetType(MP3ID3v1.Genres))
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If ListBox1.Text = "" Then
Dim r8 As DialogResult = MessageBox.Show(Me, "No File Selected!",
"Select Files", MessageBoxButtons.OK)
Else
Dim objMP3V1 As New MP3ID3v1(FolderBrowserDialog1.SelectedPath & "\" & ListBox1.SelectedItem)
If CheckBox1.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Title) = TextBox1.Text
objMP3V1.Update()
End If
If CheckBox2.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Artist) = TextBox2.Text
objMP3V1.Update()
End If
If CheckBox3.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Album) = TextBox3.Text
objMP3V1.Update()
End If
If CheckBox4.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Year) = TextBox4.Text
objMP3V1.Update()
End If
If CheckBox5.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Track) = TextBox5.Text
objMP3V1.Update()
End If
If CheckBox6.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Comment) = TextBox6.Text
objMP3V1.Update()
End If
If CheckBox7.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Genre) = ComboBox1.SelectedValue
objMP3V1.Update()
End If
Dim r9 As DialogResult = MessageBox.Show(Me, "Operation Complete!",
"Tagged Files!", MessageBoxButtons.OK)
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
ListBox1.Items.Clear()
ComboBox1.DataSource = System.Enum.GetValues(GetType(MP3ID3v1.Genres))
End Sub
End Class
What am i doing wrong?..Thanks!!
Duarte
|
|
|
|
|
Just dumping all your code and expecting someone to fix it is quite rude. We have no idea where the error occurs. So please edit the question, remove all the code that is not relevant to the problem, mark the point where the error occurs, and include the complete text of the error message.
|
|
|
|
|
Hi..sorry..i posted all the code cause i do not know what is happenning at all...
anyway...thanks and i can resume yes...
when i try to save the tags:
Dim bytTrack As Byte
Dim bytGenre As Byte
the error returns it cannot convert String to Byte..but this is only happenning in new files..if i use a pretagged file all seems good.
im using this method:
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If ListBox1.Text = "" Then
Dim r8 As DialogResult = MessageBox.Show(Me, "No File Selected!",
"Select Files", MessageBoxButtons.OK)
Else
Dim objMP3V1 As New MP3ID3v1(FolderBrowserDialog1.SelectedPath & "\" & ListBox1.SelectedItem)
If CheckBox1.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Title) = TextBox1.Text
objMP3V1.Update()
End If
If CheckBox2.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Artist) = TextBox2.Text
objMP3V1.Update()
End If
If CheckBox3.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Album) = TextBox3.Text
objMP3V1.Update()
End If
If CheckBox4.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Year) = TextBox4.Text
objMP3V1.Update()
End If
If CheckBox5.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Track) = TextBox5.Text
objMP3V1.Update()
End If
If CheckBox6.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Comment) = TextBox6.Text
objMP3V1.Update()
End If
If CheckBox7.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Genre) = ComboBox1.SelectedValue
objMP3V1.Update()
End If
Dim r9 As DialogResult = MessageBox.Show(Me, "Operation Complete!",
"Tagged Files!", MessageBoxButtons.OK)
End If
End Sub
|
|
|
|
|
You are trying to store the text strings into both those fields which are (presumably) byte types. So you need to convert the strings into their correct value types first. As someone who claims not to be a programmer, that is a lot of code that you have written.
|
|
|
|
|
Thanks...i use a lot of snippets too....so how do i convert them properly?..i already tried some methods but i could not do it!
anyway..the code is functionning for pre-tagged files...i just cannot write the properties into new files
|
|
|
|
|
I don't know how you convert them because I am not clear on what type the target is. So you need to check the definition of those fields and use an appropriate method of the Convert Class (System) | Microsoft Learn[^].
|
|
|
|
|
well..they are just the Track ID and Genre ID in an mp3 file...can i change the main code and switch them to string?...this is why i posted the full code on the start!!!
|
|
|
|
|
I don't know the answer. You first need to know what actual type they are in the file: Byte, String, Int32, Int64, Bool etc. You then need to set a matching type in your code. Then when you get the user's selection, you may or may not need to convert what the user chooses into the appropriate type. But all that detail should have been decided before you put all this code together. And I am afraid there is far too much for anyone other than you, to know where to do this.
|
|
|
|
|
i think i can do the conversion here:
Dim strTag As New String(" ", 3)
Dim strTitle As New String(" ", 30)
Dim strArtist As New String(" ", 30)
Dim strAlbum As New String(" ", 30)
Dim strYear As New String(" ", 4)
Dim strComment As New String(" ", 28)
Dim bytDummy As Byte
Dim bytTrack As Byte
Dim bytGenre As Byte
setting the "as byte" to "new string" but i do not know about the numbers here??!!!
|
|
|
|
|
As I said above, You need to match your definitions with the actual types that are used in the file. So you need to find the definition of the file types you are trying to modify and check the requirements.
|
|
|
|
|
i think is Int32
|
|
|
|
|
Fine, but you need to be certain.
|
|
|
|
|
i tried this but no luck:
If CheckBox5.Checked = True Then
Dim txt = TextBox5.Text
Dim tt As Integer = Convert.ToInt32(txt)
tt = objMP3V1.Frame(MP3ID3v1.FrameTypes.Track) & vbLf
objMP3V1.Update()
End If
If CheckBox6.Checked = True Then
objMP3V1.Frame(MP3ID3v1.FrameTypes.Comment) = TextBox6.Text
objMP3V1.Update()
End If
If CheckBox7.Checked = True Then
Dim xt = ComboBox1.SelectedValue
Dim xx As Integer = Convert.ToInt32(xt)
xx = objMP3V1.Frame(MP3ID3v1.FrameTypes.Genre) & vbLf
objMP3V1.Update()
End If
|
|
|
|
|
Member Alienoiz wrote: i tried this but no luck: Why are you trying to store 32 bit integer values in 8 bit byte fields?
|
|
|
|
|
well..,like i say..im no coder...i just read snippets and try by error!
|
|
|
|
|
can it be here?
' Fix the length of the frames
strTitle = LSet(mobjFrame(0), Len(strTitle))
strArtist = LSet(mobjFrame(1), Len(strArtist))
strAlbum = LSet(mobjFrame(2), Len(strAlbum))
strYear = LSet(mobjFrame(3), Len(strYear))
bytTrack = mobjFrame(4)
strComment = LSet(mobjFrame(5), Len(strComment))
bytGenre = mobjFrame(6)
sorry im blind about it for now (
|
|
|
|
|
Sorry, I really have no idea what that code is trying to do, so I cannnt say whether it is correct or not.
|
|
|
|
|
hey..i changed my library..im now using UltraID3lib.....it seems im making it but i have another question...
how do i make mass edit in a listbox?
im using this code that was working previously but is not working now:
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If ListBox1.SelectedItem = "" Then
Dim r8 As DialogResult = MessageBox.Show(Me, "No File Selected!",
"Select Files", MessageBoxButtons.OK)
Else
If CheckBox1.Checked = False And CheckBox2.Checked = False And CheckBox3.Checked = False And CheckBox4.Checked = False And CheckBox5.Checked = False And CheckBox6.Checked = False And CheckBox7.Checked = False Then
Dim r8 As DialogResult = MessageBox.Show(Me, "Select a tag to enter!",
"Select Tags", MessageBoxButtons.OK)
Else
Dim fil = ListBox1.SelectedItems
Dim fil2 As String
For Each fil2 In fil
If CheckBox1.Checked = True Then
myMp3.ID3v2Tag.Title = TextBox1.Text
myMp3.Write()
End If
If CheckBox2.Checked = True Then
myMp3.ID3v2Tag.Artist = TextBox2.Text
myMp3.Write()
End If
If CheckBox3.Checked = True Then
myMp3.ID3v2Tag.Album = TextBox3.Text
myMp3.Write()
End If
If CheckBox4.Checked = True And TextBox4.Text <> "" Then
On Error Resume Next
myMp3.ID3v2Tag.Year = Short.Parse(TextBox4.Text)
myMp3.Write()
On Error Resume Next
End If
If CheckBox5.Checked = True And TextBox5.Text <> "" Then
myMp3.ID3v2Tag.TrackNum = Short.Parse(TextBox5.Text)
myMp3.Write()
On Error Resume Next
End If
If CheckBox6.Checked = True Then
myMp3.ID3v2Tag.Comments = TextBox6.Text
myMp3.Write()
End If
If CheckBox7.Checked = True Then
If ComboBox1.Text = "01 - User" Then
myMp3.ID3v2Tag.Genre = TextBox7.Text
myMp3.Write()
Else
myMp3.ID3v2Tag.Genre = ComboBox1.Text
myMp3.Write()
End If
End If
Next
Dim r9 As DialogResult = MessageBox.Show(Me, "Operation Complete!",
"Tagged Files!", MessageBoxButtons.OK)
End If
End If
can you help with this? thanks
|
|
|
|
|
Sorry, I have no idea what you mean by "this code that was working previously but is not working now:". You need to explain what happens when you run this code and why that is not correct. Alternatively, use the debugger to step through the code to try and find out what is going on.
|
|
|
|
|
well...i just want to apply this code
If CheckBox6.Checked = True Then
myMp3.ID3v2Tag.Comments = TextBox6.Text
myMp3.Write()
End If
If CheckBox7.Checked = True Then
If ComboBox1.Text = "01 - User" Then
myMp3.ID3v2Tag.Genre = TextBox7.Text
myMp3.Write()
Else
myMp3.ID3v2Tag.Genre = ComboBox1.Text
myMp3.Write()
End If
End If
........to all selected items in a listbox!!
|
|
|
|
|