Try something like this, i dont have a compiler nearby but this cant be far off
Dim bedspace as generic.list(of integer) = (From bed In HMS.Beds Where bed.BedName.Contains("ward")
Select bed.BedName.Substring(4).ToString).tolist
If bedspace.Count <> 0 Then
txtProvisonalDiagnosis.Text = bedspace.Max
Else
txtProvisonalDiagnosis.Text = "am still a sucker"
End If