che errore ti da ?
cmq, prima di richiamare la proprietà .Length devi controllare che il metodo GetFiles non ritorni oggetto nullo..
Partial Class mappe_prova_variabile
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim di As New IO.DirectoryInfo(Server.MapPath("../../public/allegati/foto"))
If Not di.GetFiles("*.jpg") Is Nothing Then
Dim totale As Integer = a + di.GetFiles("*.jpg").Length
Response.Write(totale)
End If
End Sub
End Class