比如:我定义
Public Function FormatStr(ByVal ob As Object) As String
If ob.ToString().Trim() = "" Then
FormatStr = ""
Else
FormatStr = ob.ToString().Trim().Substring(0, 2) + ":" + ob.ToString().Trim().Substring(2, 2)
End If
End Function
Private Sub ma()
................
End Sub 程序中所有页面都要调用这两个函数,我应该把他们放在什么地方,怎样读取调用?????
Public Function FormatStr(ByVal ob As Object) As String
If ob.ToString().Trim() = "" Then
FormatStr = ""
Else
FormatStr = ob.ToString().Trim().Substring(0, 2) + ":" + ob.ToString().Trim().Substring(2, 2)
End If
End Function
Private Sub ma()
................
End Sub 程序中所有页面都要调用这两个函数,我应该把他们放在什么地方,怎样读取调用?????
Public Class Common
Inherits System.Web.UI.Page Public Function FormatStr(ByVal ob As Object) As String
If ob.ToString().Trim() = "" Then
FormatStr = ""
Else
FormatStr = ob.ToString().Trim().Substring(0, 2) + ":" + ob.ToString().Trim().Substring(2, 2)
End If
End Function Private Sub ma()
''................
End Sub
End Class2、修改页面类的定义:Public Class WebForm1
Inherits System.Web.UI.Page
为:
Public Class WebForm1
Inherits Common
祝你成功!!!
------------------------------------
那页面怎么调用呢?????
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = FormatStr("1220")
End Sub
Public Class Common
Inherits System.Web.UI.Page Public Function FormatStr(ByVal ob As Object) As String
If ob.ToString().Trim() = "" Then
FormatStr = ""
Else
FormatStr = ob.ToString().Trim().Substring(0, 2) + ":" + ob.ToString().Trim().Substring(2, 2)
End If
End Function Private Sub ma()
''................
End Sub
End Class2、修改页面类的定义:Public Class WebForm1
Inherits System.Web.UI.Page
为:
Public Class WebForm1
Inherits Common
{
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = FormatStr("1220")
End Sub
}