在vb.net中使用区域性时在vb.net中查询Querry? [英] Querry in vb.net while using culture in vb.net?
问题描述
您好,先生,
主席先生,我已经自行控制了日历,现在我想将该日历转换为印地文,但是当我使用这种文化进行这项工作时,会出现错误,即; "从字符串"06-29-2011"到类型日期"的转换无效".
现在我无法理解如何将日期转换为特定的文化,即;印地文?
先生,我想分享一些代码
Hello Sir,
Sir i have made a calenar control by own and now i want to convert that calendar in hindi but as i use the culture for this work it gives error ie; "Conversion from string "06-29-2011" to type ''Date'' is not valid".
Now i am unable to understand that how to convert the date into the specific culture ie; hindi?
Sir i wanna share some code
Protected Sub MonthPage_ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles MonthPage_ImageButton1.Click
Dim cultureInfo As New CultureInfo("hi-IN")
Thread.CurrentThread.CurrentCulture = cultureInfo
cultureInfo.DateTimeFormat.Calendar = New GregorianCalendar
Dim dnow As DateTime = Now() 'take a dnow variable as a datetime.
Error is coming here: ReloadCal(dnow.ToString("MM/dd/yyyy")) ''Call the function Reloadcal to dispaly the dates of Month and creating a calendar.
Month_PlaceHolder1.Visible = True 'show the Calendar control.
showMonth() 'call a function show month which display Current onth at calendar.
GetMonthName() 'call a function getmonthname which display numeric value of month.
Monthpage_TextBox1.Text = "" 'take a textbox and empty it.
End Sub
Public Sub ReloadCal(ByVal ldate As Date) 'creating a function to create calendar and display dates on it.
On Error Resume Next 'Proceed the next line after comming the error .
Me.Refresh() 'Call Refresh function to refresh the backgroung image for date in calendar.
Me.ClearAll() 'clear all the text of linkbuttons for date.
Dim fdate As DayOfWeek = GetFirstOfMonthDay(ldate) 'take a fdate variable as dayofweek. and assign the result ehich is getting form the function GetFirstOfMonthDay().
Dim idate As Integer = 1 'take a variable idate as integer and assign it to 1.
Dim row As Integer = 1 'take a variable row as integer and assign it to 1.
Do
getlinkbutton(fdate, row).Text = idate 'call a function getlinkbutton which didsplay all the dates at calendar.
If fdate = DayOfWeek.Saturday Then 'here check the end of the week is saturday or not.
row += 1 'increment the row of table .
End If
fdate = tdate(fdate) 'assign the result of function tdate in fdate variable.
idate += 1 'increment the idate .
If idate = Date.DaysInMonth(ldate.Year, ldate.Month) + 1 Then 'check here is the date is the last date of the month taht it is 31 or 30 according to system date .
Exit Do 'if it is the last date of month then exit from do while loop.
End If
Loop ' end of the do while loop.
End Sub
请提供任何可能的解决方案.
谢谢
[edit]忽略HTML ..."选项已禁用-OriginalGriff [/edit]
please give any possible solution.
Thank You
[edit]"Ignore HTML..." option disabled - OriginalGriff[/edit]
推荐答案
发现故意的错误:
Spot the deliberate mistake:
ReloadCal(dnow.ToString("MM/dd/yyyy")) ''''Call the function Reloadcal to dispaly the dates of Month and creating a calendar.
Public Sub ReloadCal(ByVal ldate As Date) ''creating a function to create calendar and display dates on it.
如果您将日期作为DateTime,为什么还要将其转换为字符串,然后尝试将其交给带有DateTime的函数,该函数将尝试使用默认区域性将其转换回DateTime?为什么不交出刚开始使用的完全有效的DateTime?
If you have the date as a DateTime, why convert it to a string, to then try to hand it to a function taking a DateTime, which will just try to convert it back to a DateTime using the default culture? Why not just hand over the fully fledged and working DateTime you started with?
这篇关于在vb.net中使用区域性时在vb.net中查询Querry?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!