I am trying to add a property called NumDBsToDisplay that gives the option of selecting between 0 and 3 databases to be displayed on my custom control. I can't get the property to show up in the designer, am I missing something here?
Here's the code:
Public Property NumDBsToDisplay(ByVal i As Integer) As Integer
Get
Dim count As Integer = 0
If cboPridb.Visible = True Then
count += 1
End If
If cboSecdb.Visible = True Then
count += 1
End If
If cboTridb.Visible = True Then
count += 1
End If
Return count
End Get
Set(ByVal value As Integer)
If value = 0 Then
cboPridb.Visible = False
cboSecdb.Visible = False
cboTridb.Visible = False
ElseIf value = 1 Then
lblPridB.Text = "Primary Database"
cboPridb.Visible = True
cboSecdb.Visible = False
cboTridb.Visible = False
ElseIf value = 2 Then
lblPridB.Text = "Primary Database"
lblSecDB.Text = "Secondary Database"
cboPridb.Visible = True
cboSecdb.Visible = True
cboTridb.Visible = False
Else
lblPridB.Text = "Primary Database"
lblSecDB.Width = 131
lblSecDB.Text = "Secondary Database"
lblTriDB.Text = "Tertiary Database"
cboPridb.Visible = True
cboSecdb.Visible = True
cboTridb.Visible = True
End If
End Set
End Property
Thank you for the help.
Related
I'm trying to do a program where the user can control the dimension of the input matrix and provide the necessary textboxes according to the desired dimension of the matrix. With my current lines of codes, this will probably reach a thousand lines despite the simplicity of the function. Is there a way to write this more efficiently? The boxes should show up every time "Load" is clicked.
If (RowDisplay.Text = "1" And ColumnDisplay.Text = "1") Then
Ta11.Visible = True
Ta21.Visible = False
Ta31.Visible = False
Ta41.Visible = False
Ta51.Visible = False
Ta12.Visible = False
Ta22.Visible = False
Ta32.Visible = False
Ta42.Visible = False
Ta52.Visible = False
Ta13.Visible = False
Ta23.Visible = False
Ta33.Visible = False
Ta43.Visible = False
Ta53.Visible = False
Ta14.Visible = False
Ta24.Visible = False
Ta34.Visible = False
Ta44.Visible = False
Ta54.Visible = False
Ta15.Visible = False
Ta25.Visible = False
Ta35.Visible = False
Ta45.Visible = False
Ta55.Visible = False
ElseIf (RowDisplay.Text = "2" And ColumnDisplay.Text = "1") Then
Ta11.Visible = True
Ta21.Visible = True
Ta31.Visible = False
Ta41.Visible = False
Ta51.Visible = False
Ta12.Visible = False
Ta22.Visible = False
Ta32.Visible = False
Ta42.Visible = False
Ta52.Visible = False
Ta13.Visible = False
Ta23.Visible = False
Ta33.Visible = False
Ta43.Visible = False
Ta53.Visible = False
Ta14.Visible = False
Ta24.Visible = False
Ta34.Visible = False
Ta44.Visible = False
Ta54.Visible = False
Ta15.Visible = False
Ta25.Visible = False
Ta35.Visible = False
Ta45.Visible = False
Ta55.Visible = False
End If
While I probably wouldn't recommend using all those TextBoxes in the first place. If you're going to do it that way, put them all in the same Panel, TableLayoutPanel or FlowLayoutPanel, then you can do this:
Private Sub DisplayTextBoxes(count As Integer)
For i = 0 To myContainer.Controls.Count - 1
myContainer.Controls(i).Visible = (i < count)
Next
End Sub
If, for instance, you call that with a count of 2, the controls at index 0 and 1 will have Visible set to True and the rest will have Visible set to False.
For the first time when I run my window application it will successfully run, but when I change the database column and binding then it gives me an error that specific data column is not there in database; also I am make null chart datasource but it gives an error. Please help.
Dim ctrArr As Integer
Dim serCnt As Integer
Dim series1 As New Series
Dim seriesFound As Boolean = False
For serCnt = 0 To ctrChart.Series.Count - 1
ctrChart.Series(0).ArgumentDataMember = ""
ctrChart.Series(0).ValueDataMembers(0) = ""
ctrChart.Series(0).Visible = False
Next
For ctrArr = 0 To gStrYAxisParamArray.Length - 1 'deptname'
For serCnt = 0 To ctrChart.Series.Count - 1
If UCase(Trim(gStrYAxisParamArray(ctrArr))) = UCase(ctrChart.Series(serCnt).Name.ToString) Then
ctrChart.Series(serCnt).ArgumentDataMember = ""
ctrChart.Series(serCnt).ValueDataMembers(0) = ""
ctrChart.Series(serCnt).Visible = True
ctrChart.Series(serCnt).ArgumentDataMember = gxAxis
ctrChart.Series(serCnt).ValueDataMembers.Item(0) = Trim(gStrYAxisParamArray(ctrArr))
seriesFound = True
Exit For
End If
Next
If seriesFound = False Then
series1 = New Series(Trim(gStrYAxisParamArray(ctrArr)).ToString, ViewType.Bar)
'ctrChart.Series.AddRange(New Series() {series1, series2})
ctrChart.Series.Add(series1)
series1.ArgumentDataMember = ""
series1.ValueDataMembers(0) = ""
series1.Visible = True
series1.ArgumentDataMember = gxAxis
series1.Label.Border.Visible = False
series1.ValueDataMembers(0) = Trim(gStrYAxisParamArray(ctrArr))
series1.LegendText = Trim(gStrYAxisParamArray(ctrArr).ToString)
End If
seriesFound = False
Next
cmbSeries.Items.Clear()
For ctrArr = 0 To ChrtStockDept.Series.Count - 1
With cmbSeries.Items
cmbSeries.Items.Add(ChrtStockDept.Series(ctrArr).Name.ToString)
End With
Next
Sorry i think this is pretty basic but I was wondering if somebody could tell me why only 1 of these IF statements seem to run. The 3rd IF statement for the "CASH" option works but the other 2 unfortunately don't.
Sub HideUnhide_Discount()
If Range("Payment_Option") = "Subscription" Then
Range("MnthD_Row").EntireRow.Hidden = False
Range("MnthD").Value = 0
Else
Range("MnthD_Row").EntireRow.Hidden = True
End If
If Range("Payment_Option") = "Lease" Then
Range("OOD_Row").EntireRow.Hidden = False
Range("Leasing_Info").EntireRow.Hidden = False
Range("OOD").Value = 0
Else
Range("OOD_Row").EntireRow.Hidden = True
Range("Leasing_Info").EntireRow.Hidden = True
End If
If Range("Payment_Option") = "Cash" Then
Range("OOD_Row").EntireRow.Hidden = False
Range("MnthD_Row").EntireRow.Hidden = False
Range("OOD").Value = 0
Else
Range("OOD_Row").EntireRow.Hidden = True
Range("MnthD_Row").EntireRow.Hidden = True
End If
End Sub
Try replacing your multiple If >> Else condition with the Select Case below:
Sub HideUnhide_Discount()
' first reset all rows to be visible , later according to the value, unhide specific rows
Range("MnthD_Row").EntireRow.Hidden = True
Range("OOD_Row").EntireRow.Hidden = True
Range("Leasing_Info").EntireRow.Hidden = True
Select Case Range("Payment_Option")
Case "Subscription"
Range("MnthD_Row").EntireRow.Hidden = False
Range("MnthD").Value = 0
Case "Lease"
Range("OOD_Row").EntireRow.Hidden = False
Range("Leasing_Info").EntireRow.Hidden = False
Range("OOD").Value = 0
Case "Cash"
Range("OOD_Row").EntireRow.Hidden = False
Range("MnthD_Row").EntireRow.Hidden = False
Range("OOD").Value = 0
End Select
End Sub
I'm trying to validate a postcode from a user input within a form. Using this class, i'm trying to search through every character and check it. Then to call in within the form I have used the latter code.
The problem i'm having is that an error pops up saying
"Conversion from string "True0" to type 'Double' is not valid."
Function VaidatePostCode(ByVal Post As String) As String
For C = 0 To Len(Post) - 1
If Char.IsLetter(Post(C)) & C = 0 Then
_boolvalid = True
Else
_boolvalid = False
End If
If Char.IsLetter(Post(C)) & C = 1 Then
_boolvalid = True
Else
_boolvalid = False
End If
If Char.IsNumber(Post(C)) & C = 2 Then
_boolvalid = True
Else
_boolvalid = False
End If
If Char.IsWhiteSpace(Post(C)) & C = 3 Then
_boolvalid = True
Else
_boolvalid = False
End If
If Char.IsNumber(Post(C)) & C = 4 Then
_boolvalid = True
Else
_boolvalid = False
End If
If Char.IsLetter(Post(C)) & C = 5 Then
_boolvalid = True
Else
_boolvalid = False
End If
If Char.IsLetter(Post(C)) & C = 6 Then
_boolvalid = True
Else
_boolvalid = False
End If
Next C
Return _boolvalid
End Function
This is the code within the VB.NET form
Private Sub txtPost_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPost.Validated
If myVal.VaidatePostCode(txtPost.Text) = False Then
MsgBox("Please enter correct data format into postcode")
End If
End Sub
To check if the value is a number you can use Integer.TryParse like this:
If Not Integer.TryParse(txtPost.Text, intTemp) Then
MsgBox ...
I need your help. I would like to understand why when running ScriptManager.RegisterClientScriptBlock the controls of my page disappear and reappear only after confirmation of Ok?
Protected Sub ddlDeckFittingCategory_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlDeckFittingCategory.SelectedIndexChanged
If txbNumberofColumns.Text = "" Or Me.txbShellDiameter.Text = "" Then
ScriptManager.RegisterClientScriptBlock(Me.Page, Page.GetType, "alert", "alert('Informe o valor do Diâmetro do Casco (m)!');", True)
ddlDeckFittingCategory.SelectedValue = -1
Else
If Request("TipoTela") = 1 Then
If ddlDeckFittingCategory.SelectedValue = "Typical" Then
objFinttings_temp.IncluirFittingsTempTQIFLTTipico(Session("cod_usuario_usu"))
'objFinttings_temp.AtualizaFittingsTempColumnWell_24_in_Diam(CType(txbNumberofColumns.Text, Double))
objFinttings_temp.AtualizaFittingsTempColumnWell_24_in_Diam(txbNumberofColumns.Text)
tbFittingsFonte.Visible = True
tbFittingsFonte.HeaderText = ""
TcPrincipal.ActiveTabIndex = 6
Dim dvConsultarCodFonteEmFittingsTempPorUsuario As DataView = objFinttings_temp.ConsultarCodFonteEmFittingsTempPorUsuario(Session("cod_usuario_usu"))
Session("cod_fonte_fon") = dvConsultarCodFonteEmFittingsTempPorUsuario.Table.Rows(0)("cod_fonte_fon")
Session("ddlDeckFittingCategory") = ddlDeckFittingCategory.SelectedValue
Else
objFinttings_temp.IncluirFittingsTQIFLTDetalhado(0)
tbFittings.Visible = True
tbFittings.HeaderText = ""
TcPrincipal.ActiveTabIndex = 6
End If
GrvFittingsFonte.DataBind()
Else
If ddlDeckFittingCategory.SelectedValue = "Typical" Then
objFinttings_temp.IncluirFittingsTempTQIFLTTipico(Session("cod_usuario_usu"))
'objFinttings_temp.AtualizaFittingsTempColumnWell_24_in_Diam(CType(txbNumberofColumns.Text, Double))
objFinttings_temp.AtualizaFittingsTempColumnWell_24_in_Diam(txbNumberofColumns.Text)
tbFittingsFonte.Visible = True
tbFittingsFonte.HeaderText = ""
TcPrincipal.ActiveTabIndex = 6
Else
objFinttings_temp.IncluirFittingsTQIFLTDetalhado(Session("cod_fonte_fon"))
tbFittings.Visible = True
tbFittings.HeaderText = ""
TcPrincipal.ActiveTabIndex = 6
End If
GrvFittingsFonte.DataBind()
If ddlSelfSupportingRoof.SelectedValue = 1 Or ddlSelfSupportingRoof.SelectedValue = "-1" Then
txbNumberofColumns.Enabled = False
rvNumColuna.Visible = False
ddlEffectiveColumnDiameter.Enabled = False
rvDiametroEfetivoColuna.Visible = False
Else
txbNumberofColumns.Enabled = True
rvNumColuna.Visible = True
ddlEffectiveColumnDiameter.Enabled = True
rvDiametroEfetivoColuna.Visible = True
End If
End If
End If
End Sub
enter code here
use Page.ClientScript.RegisterStartupScript()
it will run after the page loads.