Option Explicit On : Option Strict On
Partial Public Class _Default : Inherits Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim imageFilesArr(9) As String
For I As Integer = 0 To 9
imageFilesArr(I) = String.Format("imageFiles/{0}.png", I)
Next I
Dim cnt As Integer = getCnt()
Dim wk As String = String.Format("{0:D5}", cnt)
Image1.ImageUrl = imageFilesArr(Integer.Parse(wk.Substring(0, 1)))
Image2.ImageUrl = imageFilesArr(Integer.Parse(wk.Substring(1, 1)))
Image3.ImageUrl = imageFilesArr(Integer.Parse(wk.Substring(2, 1)))
Image4.ImageUrl = imageFilesArr(Integer.Parse(wk.Substring(3, 1)))
Image5.ImageUrl = imageFilesArr(Integer.Parse(wk.Substring(4, 1)))
End Sub
Private Function getCnt() As Integer
If Session("cnt") IsNot Nothing Then
Return Convert.ToInt32(Session("cnt"))
End If
Dim CounterFilePath As String = Request.PhysicalApplicationPath & "Counter.txt"
Dim cnt As Integer
If IO.File.Exists(CounterFilePath) Then
Dim wk As String = IO.File.ReadAllText(CounterFilePath, Text.Encoding.GetEncoding("Shift-Jis"))
cnt = Integer.Parse(wk) + 1
Else : cnt = 1
End If
IO.File.WriteAllText(CounterFilePath, cnt.ToString, Text.Encoding.GetEncoding("Shift-Jis"))
Session("cnt") = cnt
Return cnt
End Function
End Class