xrjf 230 Posting Whiz

Try collections\/col(\d{2,}|[^23])(?!\/products), because (\d{2,}|[^23]) will allow 2 or more numbers (as in col22, col21) or 1 number other than 2 or 3 (col1, col4, col5 but not col2 nor col3).

xrjf 230 Posting Whiz

Of course, I meant the following (equal to 1):

dic(mid(ws.Name,3) & arr(i,1)) = 1 ' prepend the year
or

dic(arr(i,1) & mid(ws.Name,3)) = 1 ' postfix the year

xrjf 230 Posting Whiz

Assuming 'lr' is the last populated row it could be lr = .UsedRange.rows.count instead of .cells.find(...
In any case you could change line #21 to:
dic(mid(ws.Name,3) & arr(i,1)) ' prepend the year '
or
dic(arr(i,1) & mid(ws.Name,3)) ' postfix the year '
depending on the sort preference
in this manner you'll have each country once per year.

xrjf 230 Posting Whiz

I'm not sure if each time can be a withdraw of 1 unit, but in that case, calling anotherTransct() from menu(), then menu() from anotherTransact() and repeating this same process enough times, there could be a stack overflow.

xrjf 230 Posting Whiz

Remove the extra Entropy from line #48 to: cout << "The Entropy is: \t" << e << " Kj/(Kg.K)" << endl;

xrjf 230 Posting Whiz

Here I present a WebSite containing just Default.aspx.
Current snippet code has to do with coloring text in an input field of a web page. The input field is an editable DIV HTML element.
While the user writes, there is a partial post (an XMLHttpRequest) to the server. Then the code behind decides which parts of the input should be colored and which color should it be, and returns back to the client the input already formatted with color(s).
The code behind must be as fast as possible to interfere as less as possible the user input. After the formatted text is copyied to the input box (an editable DIV element) the caret position is restored and normally the user should not experience any anoying change, but when adding a line break: the caret goes to the start position.
If you to find a better solution, please let me know.
Perhaps you may want to change the Regex pattern to your needs to color words instead of math expressions: just do all the changes you want, it's up to you.

contenteditableDIV.PNG

xrjf 230 Posting Whiz

Type in Google:

w3schools customers.php
The first link appeared to have:

{ "records":[ {"Name":"Alfreds Futterkiste","City":"Berlin","Country":"Germany"}, {"Name":"Ana Trujillo Emparedados y helados","City":"México D.F.","Country":"Mexico"}, {"Name":"Antonio Moreno Taquería","City":"México D.F.","Country":"Mexico"}, {"Name":"Around the Horn","City":"London","Country":"UK"}, {"Name":"B's Beverages","City":"London","Country":"UK"}, {"Name":"Berglunds snabbköp","City":"Luleå","Country":"Sweden"}, {"Name":"Blauer See Delikatessen","City":"Mannheim","Country":"Germany"}, {"Name":"Blondel père et fils","City":"Strasbourg","Country":"France"}, {"Name":"Bólido Comidas preparadas","City":"Madrid","Country":"Spain"}, {"Name":"Bon app'","City":"Marseille","Country":"France"}, {"Name":"Bottom-Dollar Marketse","City":"Tsawassen","Country":"Canada"}, {"Name":"Cactus Comidas para llevar","City":"Buenos Aires","Country":"Argentina"}, {"Name":"Centro comercial Moctezuma","City":"México D.F.","Country":"Mexico"}, {"Name":"Chop-suey Chinese","City":"Bern","Country":"Switzerland"}, {"Name":"Comércio Mineiro","City":"São Paulo","Country":"Brazil"} ] } 
xrjf 230 Posting Whiz

Try the following

            If retVal IsNot DBNull.Value Then
                retVal += 1
            Else
                retVal = 4999
            End If
xrjf 230 Posting Whiz

Try changing line #11 to:

 $query = "SELECT username FROM user_details WHERE username='"+$username+"'";
xrjf 230 Posting Whiz

If you want to be sure 100 percent, why not set a flag pending confirmation while sending an email to the user to confirm the address?

xrjf 230 Posting Whiz

I'm not a Visual Basic advocate, I just use VBasic and like it because I code with it. Here is a 'workaround' to generate a sequence of integers and iterate through the sequence:

Module Module1
    Sub Main()
        Dim oRange As New Range(1, 100)
        For Each r In oRange
            Console.WriteLine(r.ToString)
        Next
        Console.ReadLine()
    End Sub
End Module
Public Class Range
    Implements IEnumerable
    Dim min, max As Int32
    Public Sub New(min As Int32, max As Int32)
        Me.min = min : Me.max = max
    End Sub
    Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
        Return New RangeEnum(min, max)
    End Function
End Class
Public Class RangeEnum
    Implements IEnumerator
    Dim min, max As Int32
    Dim curr As Int32
    Public Sub New(min As Int32, max As Int32)
        Me.min = min : Me.max = max : curr = min - 1
    End Sub
    Public ReadOnly Property Current As Object Implements IEnumerator.Current
        Get
            Return curr
        End Get
    End Property
    Public Sub Reset() Implements IEnumerator.Reset
        curr = min - 1
    End Sub
    Public Function MoveNext() As Boolean Implements IEnumerator.MoveNext
        curr += 1
        If curr >= min AndAlso curr <= max Then
            Return True
        End If
        Return False
    End Function
End Class
xrjf 230 Posting Whiz

Perhaps, array can do the work of Java's IntStream. For instance, to square a sequence of numbers:

    Sub Main()
        Dim arr() As Int32 = {2, 5, 6, 8, 3}
        Dim square = arr.Select(Function(x) x ^ 2)
        For i As Int32 = 0 To square.Count - 1
            Console.WriteLine(square(i).ToString)
        Next
        Console.ReadLine()
    End Sub
xrjf 230 Posting Whiz

I am almost new to lambda expressions, but thanks to you, I could write the same code in VB.Net:

Module Module1

    Dim rules As New List(Of Func(Of Int32, String)) From {
            Function(x) IIf(x Mod 15 = 0, "BAZ", ""),
            Function(x) IIf(x Mod 5 = 0, "BAR", ""),
            Function(x) IIf(x Mod 3 = 0, "FOO", "")
        }
    Sub Main()
        For i As Int32 = 1 To 100
            Console.WriteLine(i.ToString + " " + applyRules(i))
        Next
        Console.ReadLine()
    End Sub
    Function applyRules(p As Int32) As String
        Dim sRet As String = ""
        For Each rule As Func(Of Int32, String) In rules
            sRet = rule.Invoke(p)
            If sRet.Length Then
                Exit For
            End If
        Next
        Return sRet
    End Function

End Module
xrjf 230 Posting Whiz

Your language uses "," as decimal separator and "." as thousand separator and that is why instead of retrieving 1/4 (=0.25), CDbl is getting 25. Use double.parse instead, setting the NumberFormat you need:

        Dim ni As Globalization.NumberFormatInfo = Globalization.CultureInfo.CurrentCulture.NumberFormat.Clone
        ni.NumberDecimalSeparator = "."
        tara = Double.Parse(lblindicador2.Text, ni)
        PB = Double.Parse(lblindicador.Text, ni)
xrjf 230 Posting Whiz

What an old thread, isn't it?

xrjf 230 Posting Whiz

In this other way the code seems to work:

x = [16.7, 16.5, 16.1, 15, 13.5,14.2, 14.9, 13.7] # an example
D = [0, 1, 4, 7, 16, 31, 64, 127] # example
n_H = 0.9
Sec_nucli = 0

## I defined the function like this:
def Fragmentation(D,x):
    s_nucli = n_H * D * x
    return s_nucli

for xi in x: 
    for Dj in D:
      print(xi, Dj)
      Sec_nucli += Fragmentation(xi,Dj)
      print(Sec_nucli)
xrjf 230 Posting Whiz
            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

The message is telling that field pr.invno on line 1 should also figure in the Group By clause, or in a function like sum(pr.invno) or count(pr.invno) .

xrjf 230 Posting Whiz

Is it possible for you to change lines 58 and 59 from:

ra1 =  rap[j-1];
ra1 = ra1/100.0;

to:

ra1 =  rap[j-1];
printf("DEBUG: ra1 is %lf\n", ra1);
ra1 = ra1/100.0;
printf("DEBUG: ra1 is %lf\n", ra1);

and debug again?

xrjf 230 Posting Whiz

Another possibility is to assure the operation in line 59: ra1 = ra1/100.0; maybe double precision in 32 and 64 bit machines do not match the same.

xrjf 230 Posting Whiz

Where is rap[ ] assigned a value? You should look there because the value of ra1comes from rap[ ], so if the values in ra1differ it's that rap[ ]values are already coming different from some other code, not the one you show.

xrjf 230 Posting Whiz

Setting a session variable in javascript is not possible. Javascript executes on client side while php (php session variable) executes on server side, i.e. generaly on different machines.

xrjf 230 Posting Whiz

You may try Here and Click Here

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

One way could be to assign the value to a hidden input label. For example:

<?php
 $_SESSION['num']='4567890123';
?>

<!DOCTYPE html>

<html>

<body>

<script>

      function checkmax(element) {

          if(element.value.length == 9){

              var vvc = element.value;

              element.value =document.forms['myForm'].elements['h1'].value;

//alert(vvc);
          }
      }

</script>

<form name="myForm" onsubmit="myPhp.php">

<input  type="text" id="dCell" 

    value="Cellphone Number"
    maxlength="10"
    onkeypress="checkmax(this)"
    name="CellphoneNumber2"
    id="cCell"
    onblur="checkmax(this)"
    onfocus="if (this.value = '') {this.value = 'Cellphone Number';}" required>

<input name="h1" type="hidden" value="<?php echo $_SESSION['num'] ?>">
</form>
</body>
</html>
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

Sincerely, I just have tried the 'add' method for which you were asking, at least I think so. The rest of code is your task.

xrjf 230 Posting Whiz

I get no error with the above code. You may include Try-Catchs, if you do know how, and see a more explanatory error.

xrjf 230 Posting Whiz
Imports System.Data.OleDb
Public Class Form2
    Dim provider As String
    Dim dataFile As String
    Dim connString As String
    Dim sql As String
    Dim myconn As OleDbConnection = New OleDbConnection

    Event UpdateDGV()
    Private currentRowIdentifier As Integer

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
    End Sub

    Public ReadOnly Property CurrentId As Integer
        Get
            Return currentRowIdentifier
        End Get
    End Property
    Public Sub New(ByVal pIdentifier As Integer)

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        currentRowIdentifier = pIdentifier
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        myconn.Close()
        Me.Hide()
    End Sub

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ComboBox1.Items.Add("Office1")
        ComboBox1.Items.Add("Office2")
        ComboBox1.Items.Add("Key1")
        Label1.Text = "Key"
        Label2.Text = "Give"
        Label3.Text = "Name"
        Label4.Text = "Return"
        TextBox0.Visible = False
    End Sub
    Sub Add()
        provider = "provider=microsoft.jet.oledb.4.0;data source=key.mdb"
        connString = provider & dataFile
        myconn.ConnectionString = connString
        myconn.Open()
        Dim str As String
        str = "Insert into keys([key],give,[name],return) VALUES (?,?,?,?)"
        Dim cmd As OleDbCommand = New OleDbCommand(str, myconn)
        cmd.Parameters.AddWithValue("@key", ComboBox1.Text)
        cmd.Parameters.AddWithValue("@give", TextBox2.Text)
        cmd.Parameters.AddWithValue("@name", TextBox3.Text)
        cmd.Parameters.AddWithValue("@return", TextBox4.Text)
        Try
            cmd.ExecuteNonQuery()
            cmd.Dispose()
            myconn.Close()
            RaiseEvent UpdateDGV()
        Catch ex As Exception
            MessageBox.Show("Error")
        End Try
        Me.Close()
    End Sub
    Sub Edit()
        Dim main As New Form1

        If String.IsNullOrWhiteSpace(myconn.ConnectionString) Then
            myconn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=key.mdb"
        End If
        If myconn.State = ConnectionState.Closed Then
            myconn.Open()
        End If

        If ComboBox1.Text <> "" And TextBox2.Text <> "" And TextBox3.Text <> "" And TextBox4.Text <> "" Then

            sql = "UPDATE KEYS SET [1] = @key, 2 = …
xrjf 230 Posting Whiz

Besides the need of brackets for sql in reserved names as in [key] or [name], to communicate between form1 and form2 there may be a raising event.

Imports System.Data.OleDb
Public Class Form1
    Public dbconn As New OleDbConnection
    Dim adt As New OleDbDataAdapter
    Dim ds As New DataSet

    Dim datatable As New DataTable
    Dim cmd As New OleDbCommand
    WithEvents form2 As New Form2
    Dim connStr As String = "provider=microsoft.jet.oledb.4.0;data source=key.mdb"

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        dbconn.ConnectionString = connStr
        showData() 'show database values in datagridview
        Button1.Text = "Give"
        Button2.Text = "Return"
    End Sub
    Public Sub showData()
        dbconn.ConnectionString = connStr
        Dim dbcommand As String
        dbcommand = "SELECT * FROM keys"
        adt = New OleDbDataAdapter(dbcommand, dbconn)
        datatable = New DataTable
        adt.Fill(datatable)
        DataGridView1.DataSource = datatable
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        form2.Button3.Text = "Add"
        dbconn.Dispose()
        dbconn.Close()
        form2.ShowDialog()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim form As New Form2(CInt(CStr(DataGridView1.CurrentRow.Cells(0).Value)))
        form.Button3.Text = "Edit"
        form.ComboBox1.Text = DataGridView1.CurrentRow.Cells(1).Value.ToString()
        form.TextBox2.Text = DataGridView1.CurrentRow.Cells(2).Value.ToString()
        form.TextBox2.Enabled = False
        form.ComboBox1.Enabled = False
        dbconn.Dispose()
        dbconn.Close()

        form.ShowDialog()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        showData()
    End Sub

    Private Sub form2_UpdateDGV() Handles form2.UpdateDGV
        showData()
    End Sub
End Class
xrjf 230 Posting Whiz

@Josh_4 Please, take a look to the answer at your first thread Here

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

Not an improved version, but just a functional code for what you ask:

 Module Module1

    Dim vChar() As Char
    Dim vIndex() As Int32
    Dim N, r, cnt As Int32
    Sub Main()
        Try
            Console.Write("How many objects? ")
            N = Int32.Parse(Console.ReadLine)
            Console.Write("How many taken at a time? ")
            r = Int32.Parse(Console.ReadLine)
            If r >= N Then Exit Sub
            Console.WriteLine("")
            permutationsNtakenR()
            Console.ReadLine()
        Catch ex As Exception

        End Try
    End Sub
    Sub permutationsNtakenR()
        Try
            Dim i As Int32
            ReDim vChar(N - 1), vIndex(r - 1)
            For i = 0 To N - 1
                vChar(i) = ChrW(AscW("A") + i)
            Next
            Dim NPerm As Int32 = N
            For i = N - r + 1 To N - 1
                NPerm *= i
            Next
            Dim i1 As Int32
            Do
                If check(i1) Then
                    cnt += 1
                    Dsp()
                    i1 = r - 1
                End If
                vIndex(i1) += 1
                Do While vIndex(i1) = N
                    vIndex(i1) = 0
                    i1 -= 1
                    If i1 < 0 Then
                        Exit Do
                    End If
                    vIndex(i1) += 1
                Loop
            Loop While i1 >= 0

            If cnt <> NPerm Then
                Console.WriteLine("Something went wrong")
            End If
        Catch ex As Exception

        End Try
    End Sub
    Function check(ByRef ind As Int32) As Boolean
        For i As Int32 = 0 To r - 1
            For j As Int32 = i + 1 To r - 1
                If vIndex(j) = vIndex(i) Then
                    ind = j
                    Return False
                End If
            Next
        Next
        Return True
    End Function
    Sub Dsp()
        Dim str As String = String.Empty
        For i = 0 To vIndex.Length - 1 …
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

searchStringA.PNG searchStringB.PNG
The function you're asking for may well be Regex's class:

Imports System.Text.RegularExpressions

Public Class SearchCharOrString
    Private Sub btnGo_Click(sender As Object, e As EventArgs) Handles btnGo.Click
        Try
            Dim cnt As Int32 = countCharOrString(
                tbSearch.Text, tbIn.Text, chkSens.Checked)
            lblCount.Text = "Count: " + cnt.ToString
        Catch ex As Exception

        End Try
    End Sub
    Function countCharOrString(search As String, inString As String, bCaseSensitive As Boolean)

        Dim re As Regex = Nothing
        If bCaseSensitive Then
            re = New Regex(Regex.Escape(search))
        Else
            re = New Regex(Regex.Escape(search), RegexOptions.IgnoreCase)
        End If
        Dim count As Int32 = re.Matches(inString).Count
        Return count
    End Function
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

Sorry, the original file was not attached.

xrjf 230 Posting Whiz

Perhaps you'd like to emply 'mates8.dll' (in the attached file there is an example). There needs to be a reference to the dll and the imports statement. Then, you may parse simple expressions calling the Expression.parseExpression method.

mates8daniweb.PNG

Imports m8 = mates8

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
        Try
             Dim expr As m8.Expression = m8.Expression.parseExpression(tBoxExpression.Text)
            tBoxResult.Text = expr.ToString
        Catch ex As Exception

        End Try
    End Sub
End Class
xrjf 230 Posting Whiz

@Shark purinvid seems to be the table's key, so if it does not exist resultwill be 0 out from executeScalarand the row will be added. In the other case the row will be updated.

xrjf 230 Posting Whiz

Of course I suppose the student data has been entered correctly, but I can't see the need for entering a third field: status. If you want to assure the password you may constrain passwords to those containing both capital and lower letters and special characters like !,$,%, and so on. The third status field, then, can be obtained from the database when the username and password have been entered correctly.

xrjf 230 Posting Whiz

More specifically you need a File System MiniFilter which is far less complicated -although still complicated. It has a function or routine FltGetFileNameInformation (also FltGetFileNameInformationUnsafe to retrieve the file name.

xrjf 230 Posting Whiz

The code had severall errors. Maybe this other way you can make it work:

        Dim sql = "select Count(*) from pur_invdet where purinvid=@purinvid"
        Dim cmd = New OleDb.OleDbCommand(sql, cn)
        cmd.Parameters.AddWithValue("@purinvid", TextBox1.Text)
        Dim result As Integer = Convert.ToInt32(cmd.ExecuteScalar())
        cmd.Parameters.Clear()

        Try
            If result > 0 Then

                For Each x As ListViewItem In ListView1.Items
                    Dim sln As Integer = x.SubItems(0).Text
                    Dim qty As Integer = Convert.ToDecimal(x.SubItems(4).Text)
                    Dim itmid As Integer = x.SubItems(12).Text
                Next
                sql = "Update pur_invdet set [slno] = @slno, [ItemIDpur]=@ItemIDpur  where purinvid=@purinvid"
                cmd = New OleDb.OleDbCommand(sql, cn)
                cmd.Parameters.AddWithValue("@slno", Val(txtitemsl.Text))
                cmd.Parameters.AddWithValue("@ItemIDpur", txtitemid.Text)
                cmd.Parameters.AddWithValue("@purinvid", txtpurinvid.text)
                Dim n As Int32 = cmd.ExecuteNonQuery()
                If n Then
                    MsgBox("Updated ")
                End If
            Else

                sql = "Insert into pur_invdet (slno, ItemIDpur,purinvid) values (@slno, @ItemIDpur, @purinvid)"
                cmd = New OleDb.OleDbCommand(sql, cn)
                cmd.Parameters.AddWithValue("@slno", Val(txtitemsl.Text))
                cmd.Parameters.AddWithValue("@ItemIDpur", txtitemid.Text)
                cmd.Parameters.AddWithValue("@purinvid", txtpurinvid.text)
                Dim n As Int32 = cmd.ExecuteNonQuery()
                If n Then
                    MsgBox("Saved")
                End If
            End If
            cmd.Dispose()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
xrjf 230 Posting Whiz

You are setting just one parameter in the Update statement while adding later 3 parameters. Can't you include the execute cmd.executeNonQuerys inside a try - catch to see if there is any error message?

xrjf 230 Posting Whiz

Change lines #21 and 22 into the following to see how many registers are really updated:

           dim n as int32 = cmd.ExecuteNonQuery() 'n=The number of rows affected'
           MsgBox("Updated "+n.tostring+" rows")

Change lines #30 and 31 into the following and see how many registers are really saved:

           dim n as int32= cmd.ExecuteNonQuery() 'n=The number of rows affected'
           MsgBox("Saved " + n.tostring + " rows")
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