Dim vplaats() As String = Split(Replace(TextBox1.Text, "'", "''"), " ")
vplaats(0) = StrConv(vplaats(0), VbStrConv.ProperCase)
vplaats(vplaats.Length - 1) = StrConv(vplaats(vplaats.Length - 1), VbStrConv.ProperCase)
Dim platts As String = Join(vplaats, " ")
xrjf 230 Posting Whiz
Then call by means of XMLHttpRequest another php that grabs the phone number and any other data to record what is necessary.
<script>
function checkmax(element) {
if(element.value.length == 9){
var xhr = new XMLHttpRequest();
xhr.open('POST', '/server/getPhone.php', true);
//Send the header
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {//Call a function when the state changes.
if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
// Request finished. Do processing here.
}
xhr.send("phone="+urlencode(element.value)+"&foo=bar");
}
}
</script>
xrjf 230 Posting Whiz
I agree in that the only way I can see is to submit the form back to the server. Something like:
<!DOCTYPE html>
<html>
<body>
<script>
function chkLen() {
if(document.getElementById("dCell").value.length =10)
document.getElementById("myForm").submit();
}
</script>
<form name="myForm" onsubmit="myPhp.php">
<input id="dCell" type="text" onChange="chkLen();" value="<?php echo $_SESSION['mySessionIDHere'];?>" />
</form>
</body>
</html>
xrjf 230 Posting Whiz
The xml file should look like the following:
<?xml version="1.0" encoding="UTF-8"?>
<Programme Path="1">
<Feld Icon="Folder.ico" Path="2">Feld 1<VisualStudio Path="C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" Icon="VS.png">Visual Studio</VisualStudio>
<Excel Path="C:\Program Files\Microsoft Office 15\root\office15\EXCEL.EXE" Icon="Excel.png">Excel</Excel>
</Feld>
<Home Icon="Folder.ico" Path="3">Home Place<Notepad Path="C:\Program Files\Notepad++\notepad++.exe" Icon="notepad.png">Notepad ++</Notepad>
<JaTool Path="C:\Program Files (x86)\Tool7\javaw.exe" Argumente="-splash:splash.png -cp ./cl/cl.jar; -Dawt.useSystemAAFontSettings=on" Icon="JaTool.ico" RunPath="C:\Program Files (x86)\Tool7\bin\..">JaTool</JaTool>
</Home>
</Programme>
xrjf 230 Posting Whiz
The easiest way to store the attributes is in a new class, in order to extend the NodeTree class. So when reading the xml attributes, store them in this -let's call it- 'extendNode' class. Then, in the TreeView node all it's needed is to set the node's 'Tag' property to the 'extendNode' instance where the attributes are.
Imports System.Xml
Imports System.IO
Imports System.Text
Public Class treeViewLoadXml
Dim imgLst As New ImageList
Dim vImgPath(-1) As String, iv As Int32 = 0
Private Sub treeViewLoadXml_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Load_XML()
End Sub
Public Sub Load_XML()
Try
' Get Xml's file stream.
imgLst.ImageSize = New Drawing.Size(30, 27)
Dim vPath() As String = Split(Application.ExecutablePath, "\")
vPath(vPath.Length - 1) = "XMLFile2.xml"
Dim filepath As String = Join(vPath, "\")
Dim _rstream As New FileStream(filepath, FileMode.Open)
' Load Xml document.
'
Dim dom As New XmlDocument()
dom.Load(_rstream)
_rstream.Close()
' Initialize treeView control.
'
TreeView1.BeginUpdate()
TreeView1.Nodes.Clear()
TreeView1.Nodes.Add(New TreeNode(dom.DocumentElement.Name))
' Populate the treeView with the dom nodes.
'
AddNode(dom.DocumentElement, TreeView1.Nodes(0))
If iv Then
For i = 0 To iv - 1
imgLst.Images.Add(Image.FromFile(vImgPath(i)))
Next
TreeView1.ImageList = imgLst
End If
TreeView1.EndUpdate()
TreeView1.ExpandAll()
Catch xmlEx As XmlException
MessageBox.Show(xmlEx.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub AddNode(ByVal inXmlNode As XmlNode, ByVal inTreeNode As TreeNode)
Dim i As Integer
If inXmlNode.HasChildNodes Then
Dim nodeList As XmlNodeList
nodeList = inXmlNode.ChildNodes
i = 0
While i <= nodeList.Count - 1
Dim xNode As XmlNode = inXmlNode.ChildNodes(i)
Dim imgIndex As Int32 = -1
Dim eN As New extendNode ' eN …
xrjf 230 Posting Whiz
By custom arguments I mean custom attributes. In a xml file a node may have as many attributes as you wish, but Treenode control has it's own and fixed properties. In case you need to add extra attributes to Treenode you may create a custom class derived from Treenode.
xrjf 230 Posting Whiz
Think that TreeNode can't hold custom arguments. Change the xml so the path is complete:
<?xml version="1.0" encoding="UTF-8"?>
<Programme Path="1">
<Feld Icon="Folder.ico" Path="2">Feld 1<VisualStudio Path="C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" Icon="VS.png">Visual Studio</VisualStudio>
<Excel Path="C:\Program Files\Microsoft Office 15\root\office15\EXCEL.EXE" Icon="Excel.png">Excel</Excel>
</Feld>
If File.Exists(Path) Then
<Home Icon="Folder.ico" Path="3">Home Place<Notepad Path="C:\Program Files\Notepad++\notepad++.exe" Icon="notepad.png">Notepad ++</Notepad>
<JaTool Path="C:\Program Files (x86)\Tool7\javaw.exe -splash:splash.png -cp ./cl/cl.jar; -Dawt.useSystemAAFontSettings=on" Icon="JaTool.ico" RunPath="C:\Program Files (x86)\Tool7\bin\..">JaTool</JaTool>
</Home>
</Programme>
and then change the following:
If File.Exists(Path) Then
Process.Start(Path)
'Dim MyProcess As New Process()
'MyProcess.StartInfo.FileName = Path
'MyProcess.StartInfo.Arguments = Argumente '(optional)
Dim pos As Int32 = InStr(Path, " -")
'MyProcess.Start()
End If
by:
Dim pos As Int32 = InStr(Path, " -")
Dim Argumente As String = ""
If pos Then
Argumente = Mid(Path, pos)
Path = Mid(Path, 1, pos - 1)
End If
If File.Exists(Path) Then
Process.Start(Path, Argumente)
End If
xrjf 230 Posting Whiz
I'm not gonna give a neg. rep. point, not even discuss what does lambda syntax look like in any specific language. Just that if this is a vb.net thread it's not a c# or not even asp.net. Isn't it?
ddanbe commented: Completely right, and well said! +15
xrjf 230 Posting Whiz
Six thousand rows doesn't seem so much, unless having constant calls to the function.
Imports System.Linq
Public Class Properties
Private Sub Properties_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim A1() As A = {New A(1, "name1", "address1", "email1@email.com", "1234", "NY"),
New A(2, "name2", "address2", "email2@email.com", "5678", "LA"),
New A(3, "name3", "address3", "email3@email.com", "9012", "XX")}
Dim q = (From p In A1 Select ID = p.ID,
value = p.Name + "|" + p.Address + "|" + p.email + "|" + p.phone + "|" + p.city).ToDictionary(
Function(x) x.ID, Function(x) x.value)
Dim g = q
Catch ex As Exception
End Try
End Sub
End Class
Class A
Public ID As Int32
Public Name As String
Public Address As String
Public email As String
Public phone As String
Public city As String
Public Sub New(Id As Int32,
Name As String,
Address As String,
email As String,
phone As String,
city As String)
Me.ID = Id
Me.Name = Name
Me.Address = Address
Me.email = email
Me.phone = phone
Me.city = city
End Sub
End Class
xrjf 230 Posting Whiz
@ddanbe why don't express lambda expressions in VB.NET instead of c#?
xrjf 230 Posting Whiz
Do you mean somewhat like this?:
Imports System.Linq
Public Class Properties
Private Sub Properties_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim A1() As A = {New A(1, "name1", "address1"),
New A(2, "name2", "address2"),
New A(3, "name3", "address3")}
Dim q = (From p In A1 Select p.ID, p.Address).ToDictionary(Function(x) x.ID, Function(x) x.Address)
Catch ex As Exception
End Try
End Sub
End Class
Class A
Public ID As Int32
Public Name As String
Public Address As String
Public Sub New(Id As Int32, Name As String, Address As String)
Me.ID = Id
Me.Name = Name
Me.Address = Address
End Sub
End Class
xrjf 230 Posting Whiz
Searching seems as there is an issue in CrystalReports. Can't you divide, as a workaround, the report in two or three so each one has less than 2^15=32768 pages?
rproffitt commented: Divide and conquer. Then rule. +12
xrjf 230 Posting Whiz
Well, both tables must be read. You may code something like:
Public Sub Displayitem()
Dim cmd As New OleDb.OleDbCommand("SELECT * FROM pur_inv,inv_type WHERE pur_inv.invtypid=inv_type.invtypid ORDER BY purinvdt", cn)
Dim dr As OleDb.OleDbDataReader = cmd.ExecuteReader()
ListView1.Items.Clear()
Do While dr.Read()
Dim new_item As New _
ListViewItem(dr.Item("purinvdt").ToString)
new_item.SubItems.Add(dr.Item("purinvid").ToString)
new_item.SubItems.Add(dr.Item("prtid").ToString)
new_item.SubItems.Add(dr.Item("pur_inv.invtypid").ToString)
new_item.SubItems.Add(dr.Item("taxamt").ToString)
new_item.SubItems.Add(dr.Item("tottaxblamt").ToString)
new_item.SubItems.Add(dr.Item("invamt").ToString)
ListView1.Items.Add(new_item)
Loop
End Sub
xrjf 230 Posting Whiz
rproffitt commented: Should be interesting to see Mr.M's take on this answer. Good find. +12
xrjf 230 Posting Whiz
Thank you for your confidence.
xrjf 230 Posting Whiz
Sorry, I thought your code was for WPF. So, it should be:
Public Sub listView1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles ListView1.KeyDown
If e.Modifiers = Keys.Alt AndAlso _
e.KeyCode = Keys.Delete Then
If ListView1.SelectedItems.Count Then
Dim item As ListViewItem = ListView1.SelectedItems(0)
ListView1.Items.Remove(item)
e.Handled = True
End If
End If
End Sub
xrjf 230 Posting Whiz
If product names are really the same in both datagridview, i.e., no need to add rows:
Dim us As New Globalization.CultureInfo("en-US")
Function parseN(value As String, ByRef result As Double) As Boolean
Return Double.TryParse(value, Globalization.NumberStyles.Any, us, result)
End Function
Private Sub btnCopyLeftToRight_Click(sender As System.Object, e As System.EventArgs) Handles btnCopyLeftToRight.Click
CopyDGV(DataGridViewLeft, DataGridViewRight)
End Sub
Private Sub btnCopyRightToLeft_Click(sender As System.Object, e As System.EventArgs) Handles btnCopyRightToLeft.Click
CopyDGV(DataGridViewRight, DataGridViewLeft)
End Sub
Sub CopyDGV(source As DataGridView, destination As DataGridView)
Try
With source
Dim colChk As Int32 = -1
For col As Int32 = 0 To .Columns.Count - 1
If .Columns(col).GetType Is GetType(DataGridViewCheckBoxColumn) Then
colChk = col
Exit For
End If
Next
If colChk = -1 Then
MessageBox.Show("Found no checkbox column.")
Exit Sub
End If
Dim vcolNames() As String = {"p_code", "deal_price", "unit_price", "unit_amt"}
Dim vcolIndex() As Int32 = {-1, -1, -1, -1}
For col As Int32 = 0 To .Columns.Count - 1
Dim colName As String = LCase(.Columns(col).Name)
Dim pos As Int32 = Array.IndexOf(vcolNames, colName)
If pos > -1 Then
vcolIndex(pos) = col
End If
Next
For i As Int32 = 0 To vcolIndex.Length - 1
If vcolIndex(i) = -1 Then
MessageBox.Show("Found no source column for " + vcolNames(i))
Exit Sub
End If
Next
For row As Int32 = 0 To .Rows.Count - 1
Dim chk As DataGridViewCheckBoxCell = .Rows(row).Cells(colChk)
If chk.Value Then
' verify p_code:'
Dim pcode = .Rows(row).Cells(vcolIndex(0)).Value
If pcode Is DBNull.Value Then
MessageBox.Show("Source p_code is null at line #" + (row + 1).ToString)
Exit Sub
End If
Dim pCodeB = destination.Rows(row).Cells(vcolIndex(0)).Value
If …
xrjf 230 Posting Whiz
Let's imagine population is done so there is code, product, units, price, discount and amount.
Probably you'll need to calculate the amount by clicking the 'update amount' button:
Private Sub DataGrid_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
DataGridView1.ColumnCount = 6
DataGridView1.Columns(0).Name = "Code"
DataGridView1.Columns(1).Name = "Product"
DataGridView1.Columns(2).Name = "Units"
DataGridView1.Columns(3).Name = "Price"
DataGridView1.Columns(4).Name = "Discount"
DataGridView1.Columns(5).Name = "Amount"
Dim row As String()
row = New String() {"3", "Product A", "100", "5.5", "0.0", "0"}
DataGridView1.Rows.Add(row)
row = New String() {"5", "Product B", "20", "15.0", "3.0", "0"}
DataGridView1.Rows.Add(row)
row = New String() {"6", "Product C", "300", "2.5", "5.0", "0"}
DataGridView1.Rows.Add(row)
row = New String() {"8", "Product D", "70", "10", "0.0", "0"}
DataGridView1.Rows.Add(row)
DataGridView1.Columns(0).Visible = False
Dim btn As New DataGridViewButtonColumn()
DataGridView1.Columns.Add(btn)
btn.HeaderText = "Update"
btn.Text = "Update Amount"
btn.Name = "btnUpdate"
btn.UseColumnTextForButtonValue = True
End Sub
Function parseNum(value As String) As Double
Static us As New Globalization.CultureInfo("en-US")
Dim dbl As Double
Double.TryParse(value, _
Globalization.NumberStyles.Any, us, dbl)
Return dbl
End Function
Dim us As New Globalization.CultureInfo("en-US")
Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Try
With DataGridView1
If .Columns(e.ColumnIndex).Name = "btnUpdate" Then ' update button pressed
Dim units, price, discount, amount As Double
Dim colAmount As Int32
For i = 0 To .Columns.Count - 1
Dim value = .Rows(e.RowIndex).Cells(i).Value
Select Case LCase(.Columns(i).Name)
Case "units" : units = parseNum(value)
Case "price" : price = parseNum(value)
Case "discount" : discount = parseNum(value)
Case "amount" : colAmount = i
End Select
Next
amount = units * price * (1 …
ddanbe commented: Nice! +15
xrjf 230 Posting Whiz
There is missing a catch instruction after line #15:
catch
{
}
xrjf 230 Posting Whiz
Why do you create a new instance of DataGridView in DataGridView dataGridView10 = new DataGridView();
?? You should employ the same DataGridView present in the form.
xrjf 230 Posting Whiz
I would set datagrid's property AllowUserToAddRow
to False and then manage to add a row by code. For example:
Private Sub btnNext_Click(sender As System.Object, e As System.EventArgs) Handles btnNext.Click
Try
Dim caseNum As Int32 = 0
If Int32.TryParse(tbCase.Text, caseNum) Then
With DataGridView1
Dim index As Int32 = .Rows.Count
.Rows.Add()
.Rows(index).Cells(0).Value = caseNum
End With
End If
Catch ex As Exception
Throw ex
End Try
End Sub
xrjf 230 Posting Whiz
I've tried your code and the only way I could change the window's background was setting x:Key
.
MainWindow.xaml:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Style="{StaticResource MyWindowStyle}" >
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Hello" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<TextBox Grid.Row="1" Height="25" Width="100" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
</Window>
myStyle.xaml:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="MyWindowStyle">
<Setter Property="Control.Height" Value="500" />
<Setter Property="Control.Width" Value="500" />
<Setter Property="Control.Background" >
<Setter.Value>
<SolidColorBrush Color="Red" Opacity="0.2" />
</Setter.Value>
</Setter>
<Setter Property="Window.Title" Value="Styled Window"/>
<Setter Property="Control.HorizontalAlignment" Value="Center" />
<Setter Property="Control.VerticalAlignment" Value="Center" />
<Setter Property="Window.WindowStyle" Value="None"/>
<Setter Property="Window.AllowsTransparency" Value="True"/>
</Style>
<Style TargetType="{x:Type Grid}">
<Setter Property="Height" Value="250" />
<Setter Property="Width" Value="250" />
<Setter Property="Background" Value="LightSalmon" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</ResourceDictionary>
Application.xaml:
<Application x:Class="Application"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml" >
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="myStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
xrjf 230 Posting Whiz
You may do a trick: set a numberic value to Path attribute for Programme, Felt, and so on:
<?xml version="1.0" encoding="utf-8"?>
<Programme Path="1">
<Feld Icon="Folder.ico" Path="2">
Feld 1<VisualStudio Path="C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" Icon="VS.png">Visual Studio</VisualStudio>
<Excel Path="C:\Program Files\Microsoft Office 15\root\office15\EXCEL.EXE" Icon="Excel.png">Excel</Excel>
</Feld>
<Home Icon="Folder.ico" Path="3">
Home Place<Notepad Path="C:\Program Files\Notepad++\notepad++.exe" Icon="notepad.png">Notepad ++</Notepad>
</Home>
</Programme>
Then change mouse double click to examine if Path is numeric.
Private Sub me_NodeMouseDoubleClick(sender As Object, e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseDoubleClick
Try
Dim Path As String = TreeView1.SelectedNode.Name
If IsNumeric(Path) Then
Dim nAction As Int32 = Int32.Parse(Path)
Select Case nAction
Case 1
' do job for Path="1" '
Case 2
' do job for Path="2" '
Case 3
' do job for Path="3" '
End Select
Else
If File.Exists(Path) Then
Process.Start(Path)
End If
End If
Catch ex As Exception
MsgBox("kein Programm gefunden")
End Try
End Sub
Whenever you add a new folder to the XML you may set 'Path' attribute to the number of job it must do.
xrjf 230 Posting Whiz
Ok, forget the last I said and here is the code again, supposed the TreeView control is named TreeView1:
Imports System.Xml
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions
Public Class treeViewLoadXml
Dim imgLst As New ImageList
Dim vImgPath(-1) As String, iv As Int32 = 0
Private Sub treeViewLoadXml_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Load_XML()
End Sub
Public Sub Load_XML()
Try
' Get Xml's file stream.
imgLst.ImageSize = New Drawing.Size(30, 27)
Dim vPath() As String = Split(Application.ExecutablePath, "\")
vPath(vPath.Length - 1) = "XMLFile2.xml"
Dim filepath As String = Join(vPath, "\")
Dim _rstream As New FileStream(filepath, FileMode.Open)
' Load Xml document.
'
Dim dom As New XmlDocument()
dom.Load(_rstream)
_rstream.Close()
' Initialize treeView control.
'
TreeView1.BeginUpdate()
TreeView1.Nodes.Clear()
TreeView1.Nodes.Add(New TreeNode(dom.DocumentElement.Name))
' Populate the treeView with the dom nodes.
'
AddNode(dom.DocumentElement, TreeView1.Nodes(0))
If iv Then
For i = 0 To iv - 1
imgLst.Images.Add(Image.FromFile(vImgPath(i)))
Next
TreeView1.ImageList = imgLst
End If
TreeView1.EndUpdate()
TreeView1.ExpandAll()
Catch xmlEx As XmlException
MessageBox.Show(xmlEx.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub AddNode(ByVal inXmlNode As XmlNode, ByVal inTreeNode As TreeNode)
Dim i As Integer
If inXmlNode.HasChildNodes Then
Dim nodeList As XmlNodeList
nodeList = inXmlNode.ChildNodes
i = 0
While i <= nodeList.Count - 1
Dim xNode As XmlNode = inXmlNode.ChildNodes(i)
Dim imgIndex As Int32 = -1
If xNode.Attributes IsNot Nothing Then
For Each att As XmlAttribute In xNode.Attributes
If att.Name = "Icon" Then
imgIndex = addImage(att.Value)
Exit For
End If
Next
End If
Dim tNode As New TreeNode(xNode.Name)
Dim bIsTxt As Boolean = False
If tNode.Text = "#text" Then …
xrjf 230 Posting Whiz
Let's see how it goes this time. I've left commented the old instruction to visualize better the change.
Private Sub AddNode(ByVal inXmlNode As XmlNode, ByVal inTreeNode As TreeNode)
Dim i As Integer
If inXmlNode.HasChildNodes Then
Dim nodeList As XmlNodeList
nodeList = inXmlNode.ChildNodes
i = 0
While i <= nodeList.Count - 1
Dim xNode As XmlNode = inXmlNode.ChildNodes(i)
Dim imgIndex As Int32 = -1
If xNode.Attributes IsNot Nothing Then
For Each att As XmlAttribute In xNode.Attributes
If att.Name = "Icon" Then
imgIndex = addImage(att.Value)
Exit For
End If
Next
End If
Dim tNode As New TreeNode(xNode.Name)
Dim bIsTxt As Boolean = False
If tNode.Text = "#text" Then
tNode.Text = xNode.Value
bIsTxt = True
End If
If imgIndex <> -1 Then
tNode.ImageIndex = imgIndex
End If
If bIsTxt Then
'inTreeNode.Text += " " + tNode.Text '
inTreeNode.Text = tNode.Text
Else
inTreeNode.Nodes.Add(tNode)
AddNode(xNode, tNode)
End If
i += 1
End While
End If
End Sub
xrjf 230 Posting Whiz
It's more practical to change the file extension from .csv to .txt and, then, open with Excel.
xrjf 230 Posting Whiz
SELECT e.classid,
a.planname,
b.workoutname,
e.date,
c.timeslot,
e.status,
d.staffemail
FROM tblclass e
JOIN tblallocation f ON e.planallocationid = f.planallocationid
JOIN tblplan a ON a.planid = f.planid
JOIN tblworkout b ON b.workoutid = f.workoutid
JOIN tblstaff d ON d.staffid = e.staffid
JOIN tbltimeslot c ON c.timeslotid = e.timeslotid
xrjf 230 Posting Whiz
This is physics and has to do, in my opinion, with OOP more or less like physical.
The solution I think is θ' = π - θ because I should have taken PP' instead of P'P.
xrjf 230 Posting Whiz
Perhaps you are asking for DataGridView1.CellClick
event ?
xrjf 230 Posting Whiz
You must develope and install a driver. Search for MS' DDK, driver deveopment kit.
rproffitt commented: That's most likely the right way to do it. But the OP's story is untold. +12
xrjf 230 Posting Whiz
I hope it makes sense to you:
Private Sub Dgv_Formate(ByVal e As DataGridViewCellFormattingEventArgs, _
ByVal Stat As String, _
ByVal processDate As Date, _
ByVal Extra_Days As Boolean)
Try
Dim YN As Int32 = IIf(Me.DGV_Machining.Rows(e.RowIndex).Cells(Stat).FormattedValue = "n", 0, 1)
Dim extraDays As String = IIf(Not DGV_Machining.Rows(e.RowIndex).Cells(0).Value, 1, 0)
Dim procDate As Date = DGV_Machining.Rows(e.RowIndex).Cells(1).Value
Dim lt As Int32
If procDate < thisDate Then
lt = 0
ElseIf procDate > thisDate Then
lt = 1
Else
lt = 2
End If
Dim nAction As Int32 = YN * 6 + Extra_Days * 3 + lt
Select Case nAction
Case 0 : Action(e, Color.Yellow, Color.Red, False, True, False)
Case 1 : Action(e, Color.White, Color.Red, True, True, False)
Case 2 : Action(e, Color.White, Color.Red, False, True, False)
Case 3 : Action(e, Color.Yellow, Color.Black, False, False, False)
Case 4 : Action(e, Color.White, Color.Black, True, False, False)
Case 5 : Action(e, Color.White, Color.Black, False, False, False)
Case 6 : Action(e, Color.Yellow, Color.Red, False, True, True)
Case 7
Case 8
Case 9
Case 10
Case 11
End Select
Catch ex As Exception
End Try
End Sub
Sub Action(e As DataGridViewCellFormattingEventArgs, _
bkClr As Color, _
foreClr As Color, _
Bold As Boolean, _
italic As Boolean, _
_strike As Boolean)
Dim fnt As Font = Me.DGV_Machining.DefaultCellStyle.Font
With e.CellStyle
.BackColor = bkClr
.ForeColor = foreClr
Dim style As New FontStyle
If Bold Then
style = FontStyle.Bold
End If
If italic Then
style = style Or FontStyle.Italic
End If
If _strike Then
style = style Or FontStyle.Strikeout …
xrjf 230 Posting Whiz
I pass to you all the code again to be sure you can get it well.
Imports System.Xml
Imports System.Reflection
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions
Public Class treeViewLoadXml
Dim imgLst As New ImageList
Dim vImgPath(-1) As String, iv As Int32 = 0
Private Sub treeViewLoadXml_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
imgLst.ImageSize = New Drawing.Size(30, 27)
LoadXML()
End Sub
Private Sub LoadXML()
Try
' Get Xml's file stream.
Dim vPath() As String = Split(Application.ExecutablePath, "\")
vPath(vPath.Length - 1) = "XMLFile1.xml"
Dim filepath As String = Join(vPath, "\")
Dim _rstream As New FileStream(filepath, FileMode.Open)
' Load Xml document.
'
Dim dom As New XmlDocument()
dom.Load(_rstream)
_rstream.Close()
' Initialize treeView control.
'
treeView1.BeginUpdate()
treeView1.Nodes.Clear()
treeView1.Nodes.Add(New TreeNode(dom.DocumentElement.Name))
' Populate the treeView with the dom nodes.
'
AddNode(dom.DocumentElement, treeView1.Nodes(0))
If iv Then
For i = 0 To iv - 1
imgLst.Images.Add(Image.FromFile(vImgPath(i)))
Next
treeView1.ImageList = imgLst
End If
treeView1.EndUpdate()
treeView1.ExpandAll()
Catch xmlEx As XmlException
MessageBox.Show(xmlEx.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub AddNode(ByVal inXmlNode As XmlNode, ByVal inTreeNode As TreeNode)
Dim i As Integer
If inXmlNode.HasChildNodes Then
Dim nodeList As XmlNodeList
nodeList = inXmlNode.ChildNodes
i = 0
While i <= nodeList.Count - 1
Dim imgIndex As Int32 = -1
For Each att As XmlAttribute In inXmlNode.Attributes
If att.Name = "Icon" Then
imgIndex = addImage(att.Value)
End If
Next
Dim xNode As XmlNode = inXmlNode.ChildNodes(i)
Dim tNode As New TreeNode(xNode.Name)
If tNode.Text = "#text" Then
tNode.Text = xNode.Value
End If
If imgIndex <> -1 Then
tNode.ImageIndex = imgIndex
End If
inTreeNode.Nodes.Add(tNode) …
xrjf 230 Posting Whiz
Yes, sorry, you must remove baseStream so the instruction in line #11 will be dom.Load(_rStream)
xrjf 230 Posting Whiz
Then copy the xml file to the executable's folder and replace what now is commented by the uncommented:
' Get Xml's file stream.
'Dim _assembly As [Assembly] = [Assembly].GetExecutingAssembly
''Dim _stream As Stream = _assembly.GetManifestResourceStream("MyNameSpace.XMLFile1.xml")
''Dim _rStream As New IO.StreamReader(_stream)
'
Dim vPath() As String = Split(Application.ExecutablePath, "\")
vPath(vPath.Length - 1) = "XMLFile1.xml"
Dim filepath As String = Join(vPath, "\")
Dim _rstream As New FileStream(filepath, FileMode.Open)
xrjf 230 Posting Whiz
Each time you compile in VS, the xml file is embedded into the .exe file.
xrjf 230 Posting Whiz
I am not very sure if I have understood. The xml file can be modified inside or outside VS, but because it's embedded it goes 'inside' the .exe file. This is, if you copy the executable .exe file to another folder you are also copying the xml file because it's inside the executable (=embedded).
xrjf 230 Posting Whiz
In Visual Studio explorer right click over the application name and add a new element: a xml file. Paste the xml text inside the new xml file. Next, right click (in VS explorer) over the xml file name and select "properties" (I am translating from spanish) and in "Compile actions" set option "embedded file".
Finally change "MyNameSpace.XMLFile1.xml" to your name space and file name.
You may find the 'MyNameSpace' in the application properties, "application" tab, box "root namespace".
Change 'XMLFile1.xml' by the name you have given to the file.
xrjf 230 Posting Whiz
I hope this helps:
Dim rdr As SqlDataReader = cmd.ExecuteReader
Dim bFound As Boolean = False
If rdr.Read() Then
Dim category As String = rdr("categoryname")
If txtcontent = category Then
bFound = True
End If
End If
rdr.Close()
If Not bFound Then
cmd = New SqlCommand(query2, connect)
x = cmd.ExecuteNonQuery
lblResult.Text = "New category added"
End If
xrjf 230 Posting Whiz
Perhaps a better approximation may be this 'simpler' code:
Imports System.Xml
Imports System.Reflection
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions
Public Class treeViewLoadXml
Dim imgLst As New ImageList
Dim vImgPath(-1) As String, iv As Int32 = 0
Private Sub treeViewLoadXml_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
imgLst.ImageSize = New Drawing.Size(30, 27)
LoadXML()
End Sub
Private Sub LoadXML()
Try
' Get Xml's file stream.
'
Dim _assembly As [Assembly] = [Assembly].GetExecutingAssembly
Dim _stream As Stream = _assembly.GetManifestResourceStream("MyNameSpace.XMLFile1.xml")
Dim _rStream As New IO.StreamReader(_stream)
' Load Xml document.
'
Dim dom As New XmlDocument()
dom.Load(_rStream.BaseStream)
' Initialize treeView control.
'
treeView1.BeginUpdate()
treeView1.Nodes.Clear()
treeView1.Nodes.Add(New TreeNode(dom.DocumentElement.Name))
' Populate the treeView with the dom nodes.
'
AddNode(dom.DocumentElement, treeView1.Nodes(0))
If iv Then
For i = 0 To iv - 1
imgLst.Images.Add(Image.FromFile(vImgPath(i)))
Next
treeView1.ImageList = imgLst
End If
treeView1.EndUpdate()
treeView1.ExpandAll()
Catch xmlEx As XmlException
MessageBox.Show(xmlEx.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub AddNode(ByVal inXmlNode As XmlNode, ByVal inTreeNode As TreeNode)
Dim i As Integer
If inXmlNode.HasChildNodes Then
Dim nodeList As XmlNodeList
nodeList = inXmlNode.ChildNodes
i = 0
While i <= nodeList.Count - 1
Dim imgIndex As Int32 = -1
For Each att As XmlAttribute In inXmlNode.Attributes
If att.Name = "Icon" Then
imgIndex = addImage(att.Value)
End If
Next
Dim xNode As XmlNode = inXmlNode.ChildNodes(i)
Dim tNode As New TreeNode(xNode.Name)
If tNode.Text = "#text" Then
tNode.Text = xNode.Value
End If
If imgIndex <> -1 Then
tNode.ImageIndex = imgIndex
End If
inTreeNode.Nodes.Add(tNode)
AddNode(xNode, tNode)
i += 1
End While
End If
End Sub
Function addImage(path As String) …
xrjf 230 Posting Whiz
If the xml is the following:
<?xml version="1.0" encoding="utf-8" ?>
<Nodes>
<Node Text="Programme" Icon="C:\Users\Public\Pictures\treeView1.bmp">
<Node Text="Test" Icon="C:\Users\Public\Pictures\treeView2.bmp">
<Programm Path="devenv.exe">Visual Studio</Programm>
<Programm Path="EXCEL.EXE">Excel</Programm>
</Node>
<Node Text="andere" Icon="C:\Users\Public\Pictures\treeView2.bmp">
<Programm Path="VB6.EXE">VB.NET</Programm>
</Node>
<Node Text="Test1" Icon="C:\Users\Public\Pictures\treeView1.bmp">
<Programm>bla</Programm>
<Programm>blup</Programm>
</Node>
</Node>
</Nodes>
and the code maybe this one:
Imports System.Xml
Imports System.Reflection
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions
Public Class treeViewLoadXml
Dim imgLst As New ImageList
Dim vImgPath(-1) As String, iv As Int32 = 0
Private Sub treeViewLoadXml_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
imgLst.ImageSize = New Drawing.Size(30, 27)
LoadXML()
End Sub
Private Sub LoadXML()
Try
' Get Xml's file stream.
'
Dim _assembly As [Assembly] = [Assembly].GetExecutingAssembly
Dim _stream As Stream = _assembly.GetManifestResourceStream("MyNameSpace.XMLFile1.xml")
Dim _rStream As New IO.StreamReader(_stream)
' Load Xml document.
'
Dim dom As New XmlDocument()
dom.Load(_rStream.BaseStream)
' Initialize treeView control.
'
treeView1.Nodes.Clear()
treeView1.Nodes.Add(New TreeNode(dom.DocumentElement.Name))
Dim tNode As TreeNode = treeView1.Nodes(0)
' Populate the treeView with the dom nodes.
'
treeView1.Nodes.Add(dom.DocumentElement.Name)
AddNode(dom.DocumentElement, tNode)
If iv Then
For i = 0 To iv - 1
imgLst.Images.Add(Image.FromFile(vImgPath(i)))
Next
treeView1.ImageList = imgLst
End If
Catch xmlEx As XmlException
MessageBox.Show(xmlEx.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub AddNode(ByVal inXmlNode As XmlNode, ByVal inTreeNode As TreeNode)
Dim xNode As XmlNode
Dim tNode As TreeNode
Dim nodeList As XmlNodeList
Dim i As Integer
If inXmlNode.HasChildNodes Then
nodeList = inXmlNode.ChildNodes
i = 0
While i <= nodeList.Count - 1
xNode = inXmlNode.ChildNodes(i)
Dim imgIndex As Int32 = -1
For Each att As XmlAttribute In inXmlNode.Attributes
If att.Name = "Icon" Then …
xrjf 230 Posting Whiz
Be sure to set ListBox1.MultiColumn property to 'True'.
xrjf 230 Posting Whiz
Well, I'm just trying to clarify my ideas of the problem and I think I have progressed: just that, nothing else. So a last thought:
If first toss is H-c2-c3 let's see a bit of what happens depending on c2, c3, c4 and c5.
T=c2 | H=c3 | H=c4, THH A wins | H=c5 HHH, no winner
| T=c5 HHT, no winner
| T=c4 THT no winner | H=c5 HTH, no winner
| T=c5 HTT, no winner
| T=c3 | H=c4, TTH B wins | H=c5 THH, A should win but does
not because of res() re-initialization
.....
xrjf 230 Posting Whiz
Seems as there are 3 factors: a 'n' or 'y' value; extra_days or not; and procesDate (<,> or =) versus thisDate.
I would suggest to you to draw a table like this one and fill in all the different possibilities. At least having a clear method to follow it'll be easier and less error prone.
Factors:
'n'/'y'.............:............'n'......................|........'y'
procDate vs.thisDate: < | = | > |
extra_Days..........: = 0 | <>0 | =0 |<>0 | = 0|<>0 |
=================================================================
Actions to take:
ForeColor...........: | |Red |Red |
BackColor...........:yellow|yellow|yellow|yellow|
Bold................: | | Yes | Yes |
Italic..............: | Yes | | Yes |
Strike..............:
xrjf 230 Posting Whiz
I'm a newbie for sql server, but I did the installation yesterday. After several errors from a .net application another pc in the home group, a list box is populated. The listbox data is retrieved from a sql server database.
I had to configure windows firewall advanced settings to let sqlserver.exe pass through Click Here .
I dissabled sql server express services and enabled sql server services, sql server browser (not sure if this last one is necesary) and protocols (Click Here)
Lastly, I remember to enable both windows and sql server authentications (https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/change-server-authentication-mode).
So, after all that the connection string became for me:
Server=servername;Database=myDataBase;User Id=sa;Password=password;
and voila!
JamesCherrill commented: Relevant and really helpfu. Excellent contribution.l +15
xrjf 230 Posting Whiz
Below lines #32 and #72 you could add these two snippets in order to remember if the checkbox is checked or not.
If InStr(sType, ".button") Then
bf.Serialize(fs, "")
ElseIf InStr(sType, ".checkbox") Then
bf.Serialize(fs, CType(ctr, CheckBox).Checked.ToString)
ElseIf InStr(sType, ".label") Then
bf.Serialize(fs, "")
End If
Dim checked As String = bf.Deserialize(fs)
If InStr(sType, ".checkbox") Then
If checked = "True" Then
CType(ctr, CheckBox).Checked = True
Else
CType(ctr, CheckBox).Checked = False
End If
End If
xrjf 230 Posting Whiz
The following code may be a poor solution, but as far as I know controls are not serializable unless having a custom serializable class for each type of control. This is a workaround. Another possibility could be to get properties through Reflexion, but again gaining complexity.
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
Public Class _De_Serialize
Dim filePath As String = "C:\Users\Public\controls.dat"
Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
Dim fs As FileStream = Nothing
Try
fs = New FileStream(filePath, FileMode.OpenOrCreate)
Dim bf As New BinaryFormatter
Dim cnt As Int32 = 0
Dim vCtl(-1) As Control
For Each ctr In Me.Controls
' ctls. having a numeric tag will be saved:'
If IsNumeric(ctr.tag) Then
ReDim Preserve vCtl(cnt)
vCtl(cnt) = ctr
cnt += 1
End If
Next
bf.Serialize(fs, cnt.ToString) ' save how many '
For i = 0 To cnt - 1
Dim ctr As Control = vCtl(i) ' next control to save'
Dim sType As String = LCase(ctr.GetType.ToString)
bf.Serialize(fs, sType)
bf.Serialize(fs, ctr.Name.ToString)
bf.Serialize(fs, ctr.Text)
bf.Serialize(fs, ctr.Location.X.ToString)
bf.Serialize(fs, ctr.Location.Y.ToString)
'...eventually save more properties '
Me.Controls.Remove(ctr)
Next
Catch ex As Exception
Finally
If fs IsNot Nothing Then
fs.Close()
End If
End Try
End Sub
Private Sub btnRestore_Click(sender As System.Object, e As System.EventArgs) Handles btnRestore.Click
Dim fs As FileStream = Nothing
Try
If Not IO.File.Exists(filePath) Then
Exit Sub
End If
fs = New FileStream(filePath, FileMode.OpenOrCreate)
Dim bf As New BinaryFormatter
' Get how many controls were saved: '
Dim cnt …