Quantcast
Channel: VBForums
Viewing all 42292 articles
Browse latest View live

Trying to enable control tab and control shift tab results in unexpected navigation

$
0
0
Hi
I have a form and an SSTab control on the form.
I am trying to add the new functionality of letting the user press control tab and control shift tab to navigate between the different tabs of this SSTab control (just like you can navigate between tabs in Firefox and other applications)

To that end, I have put this code in place:

Code:

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
  Dim XKey          As String
 
  XKey = "" & KeyCode & "-" & Shift
 
  Select Case XKey
      Case "9-2"                                ' Ctrl Tab
        If tabMain.Tab = tabMain.Tabs - 1 Then
            tabMain.Tab = 0
        Else
            tabMain.Tab = tabMain.Tab + 1
        End If
      Case "9-3"                                ' Ctrl Shift Tab
        If tabMain.Tab = 0 Then
            tabMain.Tab = tabMain.Tabs - 1
        Else
            tabMain.Tab = tabMain.Tab - 1
        End If
      Case Else
        Exit Sub
  End Select
End Sub

At first it appears that it works, but very soon, this navigation tool starts to malfunction:
Sometimes this KeyUp method is fired twice (I know this by adding some extra code to display the details on the screen), and even then instead of navigating to two tabs over, it navigates to the previous tab instead of next tab or to two tabs over.
At other times it navigates to an unexpected tab (other than the one expected)
One way to recreate this problem is to navigate between tabs in some other way and THEN press control tab for the next navigation. But the problem can be recreated in other ways too. It happens all the time.

I have used similar code numerous times before in many other applications and defined the functionalities of keys like F5, left arrow, right arrow or some other keys and it always worked without a problem. But I had never before tried this code for defining the functionality of control tab or control shift tab.
I don't know why this technique works perfectly for keys like F5 or left arrow, but not for control tab or control shift tab.

Can you please help.
Thanks.

Need some help with CreateThread in VB6

$
0
0
I'm trying to use CreateThread API call in VB6. One thing I know is that COM object functions can't be called from within the new thread. This means for example I can't do
Code:

form1.caption="test"
in the new thread. I also can't use VB-specific functions like MsgBox from within the new thread. I probably can't even reference complex structures like arrays (which are actually objects called SafeArrays, not simple memory allocations like in C or C++, so a call to MyArray(0)=10 is going to probably crash). I can only use API calls (such as GetDC, or SetPixel) and work with simple variable types such as Longs, Integers, and maybe Strings.

But I'm running into an unexpected problem. Even when I call a simple Windows API function (which should work, according to stuff I've been reading on the internet about multithreaded programs in VB6), it ends up crashing just after the Windows API function is complete. I compiled my program to EXE and loaded it into the debugger OllyDbg and looked at the disassembly of it, and executed it one step at a time. It turns out that in my ThreadProc, just after the execution of the Windows API function, another function is called. That function is __vbaSetSystemError (part of msvbvm60.dll, the VB6 virtual machine), and it has something to do with checking for errors that may have occurred in the previously called API function. I've discovered in the past that that function ALWAYS gets called after the completion of a Declared DLL function (such as a Windows API function). Unfortunately it seems that vbaSetSystemError can't be called from in another thread without crashing, and since it always gets called after Windows API (or other external dll) functions get called, there's just no way to use external dll functions from within a created thread (despite what I've read on the internet stating that it should work).

So is there some trick I can use in VB6 to allow for the calling of Windows API functions in created threads?

VS 2017 How can i prompt the user to select at least 3 checkboxes?

$
0
0
i've tried searching for an answer but all i could find was getting a maximum amount of checkboxes checked, and i want to find out how to the opposite :blush::cry:
i am making a program for ordering food and i have a groupbox of 10 checkboxes, each for a different type of topping.
i want to allow the user to select as many toppings as they want, of course, but i want them to select a minimum of 3 toppings.
im not sure if i was supposed to but
ive tried to do a do until loop
but that just kept showing me the message box and i assume it kept looping thats why i couldnt close the messagebox.
pls help.
very desperate

VS 2017 how to return back to the respective inputbox after showing the error messagebox?

$
0
0
hello!
i have a program where i have inputboxes asking the user to enter their name and number of people to reserve seats for.
ive made it so that their name input is a string data
and the number of people is a integer data
ive put try catch at the inputbox for the number of people, so that if the user enters letters, it would show a message box.
but since ive put that, its works, but after the messagebox shows, it goes back directly to the form, when actually i want it to go back to the last inputbox.
any help?:confused:

VS 2010 Project using 2D array

$
0
0
Hi, I am currently doing a project in VB 2010 where I am making a game similar to Voltorb Flip. It involves using a 2D array of face down cards containing a randomly generated number between 0 and 3. It is a 6-6 grid of these numbers however I'm trying to get the cards in the last row and column display the sum of the numbers in that row or column instead. I'm also trying to get the cards in the last row and column to display the number of zeros in that row or column as well. I managed to create a 6-6 grid where the the first 5 along and 5 down have numbers however I am having trouble with the solution for the last row and column.

Can anyone please help me out? Thanks!:)

[RESOLVED] Why String Table

$
0
0
Hi
What is the advantage of using string table resource than saving the string values in module defining Public?

[RESOLVED] Windows 10 DirectX Type Library not found...

$
0
0
Can someone explain to me where to find the DirectX Type Library in Windows 10 so that I can load it into my project? Either I am not looking in the correct place or I need to download something. I currently am running DX12 on my system. Thanks in advance.

Knowing if a server is sharing files but not wait for PING TIME OUT if not.

$
0
0
The problem is simple, my app sometimes needs to load graphic files from a LAN server.

If the server is ok, is well configured no problem.



The problem is, if the server IS NOT configured well, or just restarting, or somehow a 24hrs server is down, the app freeze its normal behaviour include when the graphics it needs to pickup are not mandatory.

Why?, to detect the server is down, it takes like 30-40 seconds? , 40 seconds the app is complete frozen, maybe terminates itself for being "hung" during those 30-40 seconds.


Test a simple... new project, insert a picture box..


and

Code:

Private Sub Form_Load()

If Dir("\\10.1.1.201\") Then

    Picture1.Picture = LoadPicture("\\10.1.1.201\abc\ff.bmp")
End If

End Sub

Being server IP not responsive, or unexisting, or maybe it is not sharing the resource, or maybe the resourse is bad configured (sharing with password protection) which my app don't support. Or any other misconfiguration....


Anyway, it is not a problem mostly, because if no server, no business.

But, what if I am running a client remotely, which is not IN THE SAME LAN!, so sharefiles does not works at all, I needs to detect this condition or a server fail condition and stops any attempt of loading a file from the server.

But, DIR (), or LoadPicture, or any synchronous function are simply overkill.


Any idea?

Remove Button from Form

$
0
0
Hello VBForums
Hello VB NET
Gentelmans ..please if you can help me to resolve my problem
To calculate the age, it is necessary to click on Button1
Without DateTimePicker .. How to remove this Button1 and write the date of birth in TextBox1 and the calculation will be done automatically in TextBox3.
This is my code :
Code:

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text > TextBox2.Text Then
            TextBox1.Text = CalculateAge(Format(TextBox2.Text, "dd/MM/yyyy"), Format(TextBox1.Text, "dd/MM/yyyy"))
        Else
            TextBox3.Text = CalculateAge(TextBox1.Text, TextBox2.Text)
        End If
    End Sub
    Function CalculateAge(ByVal vDate1 As Date, ByVal vdate2 As Date) As String
        Dim vYears As Integer, vMonths As Integer, vDays As Integer
        vMonths = DateDiff("m", vDate1, vdate2)
        vDays = DateDiff("d", DateAdd("m", vMonths, vDate1), vdate2)
        If vDays < 0 Then
            vMonths = vMonths - 1
            vDays = DateDiff("d", DateAdd("m", vMonths, vDate1), vdate2)
        End If
        vYears = vMonths \ 12
        vMonths = vMonths Mod 12
        CalculateAge = vYears & "Year " & "-" & vMonths & "Month " & "-" & vDays & "Day"
    End Function
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    TextBox2.Text = DateTime.Now.Date
    End Sub
End Class

Thank you in advance for help
Cordially
MADA

[RESOLVED] Constraint Exception

$
0
0
I am getting the following exception (again) when I execute the method below. I have stepped through the code leading up to this and have been unable to see anything that might be causing this. I have run the method, using the query builder in the tableadapter and it returns whatever record is specified. I have checked the relationships for this table and have found nothing that I know of that would cause the exception to be thrown. Additionally, I have used this or very much like this many times before with no issues.

I recall having this same issue previously and the solution turned out to be that one of the tables did not have a primary key defined. I specifically checked and that is not the case in this instance.

At this point I am at a loss as to why this exception is thrown. Let me know what additional information from me might be helpful in explaining what/why this exception is occurring.

Code:

Me.TblDocMasterTableAdapter.FillBySiTechID(Me._MasterBase5_0DataSet.tblDocMaster, glbintSiTechID)


Name:  Error.jpg
Views: 58
Size:  21.2 KB

Name:  relation.jpg
Views: 75
Size:  38.5 KB
Attached Images
   

About 2 program write text to a the same file

$
0
0
Code:

Private Sub Form_Load()
For w = 1 To 10000
Call TextFile_Write_VB("C:\1.txt",  "11" )
Next
msgbox "ok"
End Sub
'==================
Function TextFile_Write_VB(ByVal FileName As String, value As Variant) As String
Dim f1 As Long
f1 = FreeFile
Open FileName For Append As #f1
Print #f1, value
Close #f1
End Function

(1) Compile to 11.exe and 22.exe
(2) Clean "C:\1.txt"
(3) run 11.exe and 22.exe at the same time as much as possible

Result

Disk = 160G , 2007 year , Seagate , SATA2

use editor software open "C:\1.txt"

total lines = 19930 ( lost 70 lines )

Excuse me , how to can get 20000 lines in C:\1.txt with no lost ?

ArrayToPicture .PNG

$
0
0
Hello, I am developing a game in version 6.0 of visual basic. I found myself with a problem and I do not know where to go for help because visual basic is already a bit obsolete, but the game on which I base it is made here.

Step to tell that I have the resources of the game (Format .PNG) compressed through the library "zlib.dll". My idea is to extract these files and load them in a certain place. The problem is that the game comes originally in .BMP format, but I passed them to .PNG due to the need for quality.

I currently have this function

Code:

Sub DrawGrhtoHdc(ByVal desthDC As Long, ByVal grh_index As Integer, ByRef SourceRect As RECT, ByRef destRect As RECT)
    On Error Resume Next
   
    Dim file_path As String
    Dim src_x As Integer
    Dim src_y As Integer
    Dim src_width As Integer
    Dim src_height As Integer
    Dim hdcsrc As Long
    Dim MaskDC As Long
    Dim PrevObj As Long
    Dim PrevObj2 As Long
    Dim screen_x As Integer
    Dim screen_y As Integer
   
    screen_x = destRect.Left
    screen_y = destRect.Top
   
    If grh_index <= 0 Then Exit Sub

    If GrhData(grh_index).NumFrames <> 1 Then
        grh_index = GrhData(grh_index).Frames(1)
    End If
   
    Dim data() As Byte
    Dim bmpData As StdPicture
   
    'get Picture
    If Get_Image(DirGraficos, CStr(GrhData(grh_index).FileNum), data, True) Then  ' GSZAO
        Set bmpData = ArrayToPicture(data(), 0, UBound(data) + 1)
       
        src_x = GrhData(grh_index).sX
        src_y = GrhData(grh_index).sY
        src_width = GrhData(grh_index).pixelWidth
        src_height = GrhData(grh_index).pixelHeight
       
        hdcsrc = CreateCompatibleDC(desthDC)
        PrevObj = SelectObject(hdcsrc, bmpData)
       
        BitBlt desthDC, screen_x, screen_y, src_width, src_height, hdcsrc, src_x, src_y, vbSrcCopy
        DeleteDC hdcsrc
       
        Set bmpData = Nothing
    End If

End Sub

As you can see it is made for BMP because of the ArrayToPicture.

Looking for a bit more I found this

Code:

Public Sub ArrayToPicturePNG(ByRef byteArray() As Byte, ByRef imgDest As IPicture) ' GSZAO
    Call SetBitmapBits(imgDest.handle, UBound(byteArray), byteArray(0))
End Sub

Which in theory serves to replace the one above by this and thus load the .PNG but I do not know how to adapt it to the previous one that I have passed. From now, thank you for you help

Translate thanks google (Im From Argentina)

Questions about type libraries

$
0
0
I've just started learning how to make type libraries, using ODL language and the MIDL compiler. Now I've figured out how to import standard DLL functions, but I'm not completely sure about the syntax. For example in
Code:

        [
                helpstring("Kernel32 DLL"),
                dllname("KERNEL32")
        ]
        module Kernel32
        {
                [
                        helpstring("Copy Length number of bytes from Source to Destination."),
                        entry("RtlMoveMemory")
                ]
                void _stdcall CopyMemory
                (
                        [out] void *Destination,
                        [in]  void *Source,
                        [in]  int  Length
                );
        };

You can see that on the output side of the CopyMemory function I specify [out] and on the input side I specify [in], but I'm not sure if that's really needed. You see, when a function argument is used for output, you already are passing in a pointer (which the function uses to pass data back out), and the called function can do whatever it wants with that pointer. The called function is not going to reference the type library for permission on how it is going to use the pointer. So it seems that specifying [in] or [out] when defining a function argument is kind of silly. Yet it appears that [in] and [out] are part of the ODL language. So is it really required that I specify [in] or [out]? And what are the consequences of incorrectly using these, such as specifying [in] on a pointer that is used to return a value, or specifying [out] on a pointer that is used to input a value?

VS 2010 VB 2010 -Property "Range" is "ReadOnly"

$
0
0
http://www.vbforums.com/showthread.p...ge-is-ReadOnly

I have read this but this does not have any answers pertaining to the problem, in my situation. I am using

Code:

xcelSheet.cells(4,1)=Myvar
when Inserting data from VB.Net to Excel, it works fine when I'm inserting it to a blank excel sheet, but how do I do it in VB.Net? I tried using "range"


Code:

xcelSheet.RANGE("A6")=Myvar
But there pops an error that states

Code:

Property Range is ReadOnly
How can I use the Range property? I am using Vb.net 2010 professional


And, how can I mark an answer A answer?

VB 6.0 'File' Toobar has disappeared

$
0
0
I have had a friend staying for a few days so I haven't used my computer since last week. He's now departed, so I decided to continue working on my current VB 6.0 project earlier in the evening. When I reloaded the project and looked up at the Menu bar, I was amazed to note that the section of the toolbar containing the New, Open, Save, SaveAs and Print icons was missing. I am not referring to the 'File' menu - that's definitely still there - this is the File icons section of the Toolbar under the 'Menu' bar. All the other icons seems to be present. Try as I might, I cannot find that toolbar. If I select 'Toolbars' from the 'View' menu, I note there is no 'File' toolbar option in the list. I assume there should be one. Then when I select 'Customize' from the list and then 'New' and attempt to change the 'Toolbar name:' from 'Custom 1' to 'File' a message appears as follows:

"A toolbar named 'File' already exists. Type another name."

I don't recall ever having this problem before and wonder if a recent Windows 10 upgrade might have had something to do with it. (I'm using Win10 pro 64-bit).

This is a valid VB 6.0 copy which has been registered for umpteen years. I recall that when I installed it on this Win10 machine - my previous computer having failed - I had to do something a little unorthodox. I think it was a 'Custom' install but I can't remember the options I chose.

Any assistance greatly appreciated. I admit it's more an annoyance than anything else, but I would like the toolbar back, if possible.

Thank you.

[RESOLVED] Search LISTVIEW and on found Change Forecolor and uncheck the checkbox...

$
0
0
hello, all.


I have a 2 listview in my form I am transferring some lines from ListView1 (I have a Checkbox ENABLED in ListView1) to Listview2 by using Command Button. it works perfectly.

now, I want to remove some particular line from ListView2, this also works perfectly. but with that I want to FIND that particular line in ListView1 and want to change it's forecolor
and UnCheck the Checkbox of that particular line.

when I am using following code, I got error
Quote:

Runtime Error 35600 - Index out of bounds
my code is as per below
Code:

For v = 0 To ListView1.ListItems.Count - 1
        If ListView1.ListItems(v) = strVNo Then
            ListView1.SetFocus
            ListView1.SelectedItem.Index = v
            ListView1.SelectedItem.ForeColor = vbBlue
            Exit For
        End If
Next

so, where I am doing wrong ? plz. HELP.

Thanks You in advance.

Kaushal

VS 2010 need summary for programatically generated columns in gridview

$
0
0
hi
i have a report that needs to be generated from the deduction master i.e. there r n no. of deductions in the master and the report should show the deductions for the chqs. being drawn. till this its ok but the part that is confusing me is :

if there r more than 1 entries for a party then the gridview should show the total in the next line.

this is very confusing and cant think of anything how to do it. attached is the excel file showing the data have generated the summarry in excel and have marked it red to show what i need.

the cols. that r being generated r coming from a sql table deduction master.

also attached is the code for where i am generating the data.
Code:

  Private Sub GetData(ByVal xToPrint As Boolean)

        Dim dTableDet As New DataTable("dTableDedDet")
        'Dim auto As New DataColumn("SrNo", GetType(Integer))
        'auto.AutoIncrement = True
        'auto.AutoIncrementSeed = 1
        'auto.AutoIncrementStep = 1
        'dTableDet.Columns.Add(auto)

        'dTableDet.Columns.Add(New DataColumn("Date", GetType(Date)))
        dTableDet.Columns.Add(New DataColumn("SrNo", GetType(Integer)))
        dTableDet.Columns.Add(New DataColumn("PartyName", GetType(String)))
        dTableDet.Columns.Add(New DataColumn("ItemName", GetType(String)))
        dTableDet.Columns.Add(New DataColumn("ChqAmt", GetType(Integer)))
        dTableDet.Columns.Add(New DataColumn("IsSummarry", GetType(Boolean)))
        dTableDet.Columns.Add(New DataColumn("PartyCode", GetType(String)))
        mCmd = "SELECT * From DeductionMaster ORDER BY Name "
        Dim ds_Temp As New DataSet
        Dim da_Temp As New SqlDataAdapter(mCmd, MyConConnection)
        Dim dTab As New DataTable
        da_Temp.Fill(ds_Temp, "DeductionMaster")
        dTab = ds_Temp.Tables(0)
        Dim dTableDedMaster As New DataTable
        dTableDedMaster = ds_Temp.Tables("DeductionMaster")
        Dim a4ColTotal() As Double
        Dim iRowCount As Integer = dTab.Rows.Count - 1
        For i As Integer = 0 To iRowCount
            Dim iRow As DataRow = dTab.Rows(i)
            dTableDet.Columns.Add(New DataColumn(iRow!Name, GetType(Integer)))
            ReDim Preserve a4ColTotal(i + 1)
            a4ColTotal(i) = 0
        Next
        Dim mMaxCol As Integer = iRowCount + 4
        Dim mTotalDeductionCols As Integer = iRowCount
        Dim mChqNo As String = ""
        Dim mDate As Date
        dTableDet.Columns.Add(New DataColumn("GrossAmt", GetType(Integer)))
     

        Dim dNewRow As DataRow = dTableDet.NewRow
        dNewRow("PartyName") = "Meera Bhayandar Municipal Corporation"
        dTableDet.Rows.Add(dNewRow)

        dNewRow = dTableDet.NewRow
        dNewRow("PartyName") = "Accounts Department"
        dTableDet.Rows.Add(dNewRow)

        mCmd = "SELECT CB.CashBookDate, CB.CashBookSrNo, CB.GrossAmount, CB.TotalAmount, CB.RTGSGroupSerialNo, "
        mCmd = mCmd & " CB.SerialNo, CBE.ItemCode,  IM.ItemName as BudgetHead,CB.ChqNo, CB.PartyCode, PM.Name As PartyName "
        mCmd = mCmd & " FROM RTGSCashBook CB "
        mCmd = mCmd & " INNER JOIN RTGSCashBookEntry CBE ON CB.Prd_Code = CBE.Prd_Code AND CB.SerialNo  = CBE.SerialNo  "
        mCmd = mCmd & " INNER JOIN ItemMaster IM ON CBE.ItemCode = IM.ItemCode "
        mCmd = mCmd & " INNER JOIN PartyMaster PM ON CB.PartyCode = PM.Code "
        mCmd = mCmd & " WHERE CB.PRd_Code = @mPRd AND CB.RTGSGroupSerialNo = @mSrNo "
        mCmd = mCmd & " ORDER BY CB.CashBookDate, CB.RTGSGroupSerialNo, CB.PartyCode "
        Dim da_Temp2 As New SqlDataAdapter(mCmd, MyConConnection)
        Dim ds_Temp2 As New DataSet
        Dim dTab2 As New DataTable
        da_Temp2.SelectCommand.Parameters.AddWithValue("@mPRd", X_PrdCode)
        da_Temp2.SelectCommand.Parameters.AddWithValue("@mSrNo", txtGroupSrNo.Text)

        da_Temp2.Fill(ds_Temp2, "RTGSCashBook")
        dTab2 = ds_Temp2.Tables("RTGSCashBook")
        iRowCount = dTab2.Rows.Count - 1

        Dim mTotalChqAmt As Double = 0
        Dim mTotlGrossAmt As Double = 0

        MyConConnection.Open()
        For i As Integer = 0 To iRowCount
            Dim iRow As DataRow = dTab2.Rows(i)
            mChqNo = iRow!ChqNo
            mDate = iRow!CashBookDate

            Dim drNewRow As DataRow = dTableDet.NewRow
            'drNewRow("RTGSSerialNo") = iRow!RTGSGroupSerialNo
            'drNewRow("Date") = iRow!CashBookDate
            'drNewRow("DVNo") = iRow!CashBookSrNo
            drNewRow("ItemName") = iRow!BudgetHead
            drNewRow("GrossAmt") = iRow!GrossAmount
            drNewRow("PartyCode") = iRow!PartyCode
            drNewRow("IsSummarry") = False
            'drNewRow("ChqNo") = iRow!ChqNo
            drNewRow("PartyName") = iRow!PartyName
            drNewRow("SrNo") = i + 1
            mTotlGrossAmt = mTotlGrossAmt + iRow!GrossAmount

            Dim mTotalAmount As Double = 0
            mCmd = "SELECT * From DeductionMaster ORDER BY Name "
            ds_Temp = New DataSet
            da_Temp = New SqlDataAdapter(mCmd, MyConConnection)
            dTab = New DataTable
            da_Temp.Fill(ds_Temp, "DeductionMaster")
            dTab = ds_Temp.Tables(0)

            Dim iRowCount2 As Integer = dTab.Rows.Count - 1
            For i2 As Integer = 0 To iRowCount2
                Dim iRow2 As DataRow = dTab.Rows(i2)
                drNewRow(iRow2!Name) = 0
            Next

            Dim mTot As Integer = 0
            mCmd = "SELECT CBD.*, DM.Name As DedName From RTGSCashBookDet CBD "
            mCmd = mCmd & " INNER JOIN DeductionMaster DM ON CBD.Code = DM.Code "
            mCmd = mCmd & " WHERE CBD.Prd_Code = @mPRd AND CBD.SerialNo = @mSrNo "
            da_Temp = New SqlDataAdapter(mCmd, MyConConnection)
            da_Temp.SelectCommand.Parameters.AddWithValue("@mPRd", X_PrdCode)
            da_Temp.SelectCommand.Parameters.AddWithValue("@mSrNo", iRow!SerialNo)
            ds_Temp = New DataSet
            dTab = New DataTable
            da_Temp.Fill(ds_Temp, "RTGSCashBookDet")
            dTab = ds_Temp.Tables("RTGSCashBookDet")
            iRowCount2 = dTab.Rows.Count - 1
            For i2 As Integer = 0 To iRowCount2
                Dim iRow2 As DataRow = dTab.Rows(i2)
                drNewRow.Item(iRow2!DedName) = iRow2!Amount
                mTot = mTot + iRow2!Amount

                For iD As Integer = 0 To mTotalDeductionCols
                    Dim iRowDed As DataRow = dTableDedMaster.Rows(iD)
                    If iRowDed!Code = iRow2!Code Then
                        a4ColTotal(iD) = a4ColTotal(iD) + iRow2!Amount
                    End If
                Next
            Next
            'drNewRow("TotalDed") = mTot
            drNewRow("ChqAmt") = iRow!TotalAmount
            mTotalChqAmt = mTotalChqAmt + iRow!TotalAmount
            'drNewRow("SerialNo") = iRow!SerialNo
            dTableDet.Rows.Add(drNewRow)
        Next

        ''' To Show Party Wise Summarry -- trying to generate but cant think of anything

        'Dim mPName As String = ""
        'iRowCount = dTableDet.Rows.Count - 1
        'For i As Integer = 0 To iRowCount
        '    Dim iRow As DataRow = dTableDet.Rows(i)
        '    If mPName = "" Then
        '        mPName = iRow!PartyName
        '    End If



        '    mCmd = "SELECT * From DeductionMaster ORDER BY Name "
        '    ds_Temp = New DataSet
        '    da_Temp = New SqlDataAdapter(mCmd, MyConConnection)
        '    dTab = New DataTable
        '    da_Temp.Fill(ds_Temp, "DeductionMaster")
        '    dTab = ds_Temp.Tables(0)
        '    Dim drNewRow As DataRow = dTableDet.NewRow
        '    Dim mTotal As Double = 0
        '    Dim iRowCount2 As Integer = dTab.Rows.Count - 1
        '    For i2 As Integer = 0 To iRowCount2
        '        Dim iRow2 As DataRow = dTab.Rows(i2)
        '        'mTotal = mTotal + iRow2(iRow2!Name)



        '        Dim foundRows As DataRow() = dTableDet.Select("Party = " & iRow!PartyName & " - Total ")
        '        Dim mFound As Boolean = False
        '        For i22 As Integer = 0 To foundRows.GetUpperBound(0)
        '            mFound = True
        '            mTotal = iRow2(iRow2!Name) + foundRows(i2).Item(iRow2!Name)
        '        Next
        '        Dim drNewRow As DataRow
        '        If mFound = False Then
        '            mAmount = 0
        '            drNewRow = dTableRTGS.NewRow
        '            mAmount = iRow!TotalAmount
        '        Else
        '            drNewRow = foundRows(0)
        '        End If

        '    Next




        'Next
        dNewRow = dTableDet.NewRow
        dNewRow("PartyName") = "Grand Total"
        dNewRow("GrossAmt") = mTotlGrossAmt
        dNewRow("ChqAmt") = mTotalChqAmt
        mCmd = "SELECT * From DeductionMaster ORDER BY Name "
        ds_Temp = New DataSet
        da_Temp = New SqlDataAdapter(mCmd, MyConConnection)
        dTab = New DataTable
        da_Temp.Fill(ds_Temp, "DeductionMaster")
        dTab = ds_Temp.Tables(0)
        Dim iRowCount3 As Integer = dTab.Rows.Count - 1
        For i2 As Integer = 0 To iRowCount3
            Dim iRow2 As DataRow = dTab.Rows(i2)
            Dim mTempTot As Double = a4ColTotal(i2)
            dNewRow(iRow2!Name) = a4ColTotal(i2)
        Next

        dTableDet.Rows.Add(dNewRow)

        dNewRow = dTableDet.NewRow
        dNewRow("PartyName") = "Cheque No.: " & mChqNo
        dTableDet.Rows.Add(dNewRow)

        dNewRow = dTableDet.NewRow
        dNewRow("PartyName") = "Date.: " & Format(mDate, "dd-MMM-yyyy")
        dTableDet.Rows.Add(dNewRow)

        dNewRow = dTableDet.NewRow
        dNewRow("PartyName") = "Amount: " & MyFuncCollection.Num2WordConverter(mTotlGrossAmt.ToString)
        dTableDet.Rows.Add(dNewRow)


        dNewRow = dTableDet.NewRow
        dNewRow("PartyName") = "Bank Name: "
        dTableDet.Rows.Add(dNewRow)

        Dim dgMast As New GridView()
        dgMast.AutoGenerateColumns = False

        For i As Integer = 0 To dTableDet.Columns.Count - 1
            Dim boundfield As New BoundField()
            boundfield.DataField = dTableDet.Columns(i).ColumnName.ToString()
            boundfield.HeaderText = dTableDet.Columns(i).ColumnName.ToString()
            dgMast.Columns.Add(boundfield)
        Next


        '' Programmatically register the event-handling method.
        'AddHandler dgMast.RowDataBound, AddressOf RowDataBound

        dgMast.DataSource = dTableDet
        dgMast.DataBind()
        dgMast.Width = 600
        dgMast.EnableViewState = True
        dgMast.CssClass = "table table-striped table-hover table-condensed small-top-margin"

        PanDedRpt.Controls.Add(dgMast)
        ScriptManager.RegisterStartupScript(Page, Me.[GetType](), "Key", "<script>MakeStaticHeader('" + dgMast.ClientID + "', 450, 1150 , 40 ,false); </script>", False)


        'mCmd = "SELECT * From DeductionMaster Order BY Name "
        'cmd = New SqlCommand(mCmd, MyConConnection)
        'dr = (cmd.ExecuteReader)
        'While dr.Read
        '    For Each column As DataGridColumn In dgMast.Columns
        '        If column.HeaderText = dr("Code") Then
        '            column.HeaderText = dr("Name") ' String.Concat(dr("Code"), dr("Name"))
        '        End If
        '    Next
        'End While
        'dr.Close()

        Session.Add("DedictonReportChecking", dTableDet)


    End Sub

Attached Images

VS 2010 Windows 10 Visual Basic 2010 - Blur Form or Panel

$
0
0
Hello,

I've been trying to blur a panel (it can also be a form). I've found this example online (https://www.codeguru.com/columns/vb/...ith-vb.net.htm) but it's not what I want.
I want to be able to move the panel (or form) and make it blur the background. Like the blur in Windows 10: https://imgur.com/a/zPgm1

I know it's quite dificult to do this but since I'm not good with programming I hope you guys can help me out.

Thanks!

Toggling a DataGridViewCheckBoxCell?

$
0
0
I have a DataGridView that contains a single CheckBox Column along with other various columns. What I am trying to do is when a CheckBox is checked, it goes through a validation routine in the CellValueChanged Event. If certain criteria is met, the CheckBox needs to become "Unchecked". For some reason, my logic isn't working. Below is the CellValueChanged Event. I'm also utilizing the CurrentCellDirtyStateChanged Event.

Code:

    Private Sub dgvCertList_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles dgvCertList.CellValueChanged

        checkCell = CType(dgvCertList.Rows(e.RowIndex).Cells(0), DataGridViewCheckBoxCell)

        Try
            EH.ErrorMessage = String.Empty

            If blnSkipEvent Then
                iCalibrationTypeID = dgvCertList.Rows(e.RowIndex).Cells(19).Value

                If iCalibrationTypeID = 5 Then
                    stcSN.SerialNO = strKeyNO
                    stcSN.TestID = iMainID
                    stcSN.TestType = dgvCertList.Rows(e.RowIndex).Cells(5).Value
                    lstSNTestID.Add(stcSN)

                    blnRMARecal = True

                    Dim tmpTestType As String = dgvCertList.Rows(e.RowIndex).Cells(5).Value

                    For Each obj In lstSNTestID
                        If tmpTestType <> obj.TestType Then
                            RemoveHandler dgvCertList.CellValueChanged, AddressOf dgvCertList_CellValueChanged
                            checkCell.Value = False    '<----------------------- I thought this would uncheck the CheckBox
                            AddHandler dgvCertList.CellValueChanged, AddressOf dgvCertList_CellValueChanged

                            blnSkipEvent = False
                            btnAddToBuild.Enabled = False

                            DeleteArrayEntry()
                            If EH.ErrorMessage > String.Empty Then
                                GoTo ProcessMessage
                            End If

                            EH.ErrorMessage = "You cannot generate a Certificate for a System Calibration and a Standard Calibration!" & "~I"
                            GoTo ProcessMessage
                        End If
                    Next

                    btnAddToBuild.Enabled = True
                ElseIf blnChecked Then
                    checkCell = CType(dgvCertList.Rows(PreviousRowIndex).Cells(0), DataGridViewCheckBoxCell)
                    checkCell.Value = False

                    lstSNTestID.Clear()

                    stcSN.SerialNO = txtKeyNO.Text
                    stcSN.TestID = iMainID
                    lstSNTestID.Add(stcSN)

                    blnRMARecal = False
                End If
            End If

            blnSkipEvent = True

ProcessMessage:

        Catch ex As Exception
            EH.ErrorMessage = "frmCertificates/dgvCertList_CellContentClick() - " & ex.Message & "~E"
        End Try

        EH.ProcessMessages(Me, sbr, EH.ErrorMessage)

        If blnError Then
            blnError = False
            Me.dgvCertList.Rows(PreviousRowIndex).Cells(0).Value = CBool(1)
            Me.dgvCertList.Rows(e.RowIndex).Cells(0).Value = If(CType(Me.dgvCertList.Rows(e.RowIndex).Cells(0).Value, Boolean), False, True)
        End If
    End Sub
    '
    '
    '
    '
    '
    '
    Private Sub dgvCertList_CurrentCellDirtyStateChanged(sender As Object, e As EventArgs) Handles dgvCertList.CurrentCellDirtyStateChanged
        Try
            EH.ErrorMessage = String.Empty

            If dgvCertList.IsCurrentCellDirty Then
                dgvCertList.CommitEdit(DataGridViewDataErrorContexts.Commit)
            End If

        Catch ex As Exception
            EH.ErrorMessage = "frmCertificates/dgvCertList_CurrentCellDirtyStateChanged() - " & ex.Message & "~E"
        End Try

        EH.ProcessMessages(Me, sbr, EH.ErrorMessage)
    End Sub

Odd situation with Frames

$
0
0
I'm putting some controls on a Frame - and finding weird Top positions.
For example a label has a top of 350 and is about half an inch from the top of the frame.
But a text box positions beside it has a Top of 3360.

It's like the label is relative to the Form, but the Text box is relative to the Form.
Is this how it's supposed to be ?

What determines this ? Do you 'lock' a control to either the Frame, or Form somehow?
Viewing all 42292 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>