hoping this is a simple question - my coding is a bit rusty!
I've written a script to trim redundant characters from the end of (for example) the album name. I want to make it generic so I can pass in the field I want to trim.
So far I've got:
But rather than the convoluted nested if statement (or a replacement case statement) I'd like to pick the field dynamically. Something like:
Code: Select all
' Get list of selected tracks from MediaMonkey Set list = SDB.SelectedSongList If list.count=0 Then Set list = SDB.AllVisibleSongList End If If pField = "Title" Then tmp = list.item(0).Title Else If pField = "Album" Then tmp = list.item(0).AlbumName Else If pField = "Artist" Then tmp = list.item(0).ArtistName Else MsgBox "Invalid field name: " & pField, vbOKOnly + vbExclamation Exit Sub End If End If End If
tmp = list.item(0).field(pField)
So I can use pField to pick the relevant field to edit?