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

Windows 10 LTSB (Long Term Service Branch)

$
0
0
Has anyone experience with Windows 10 LTSB - long term service branch - the branch that seems to be meant for businesses to install?

Thanks!

Steve

Can I auto-move a list box

$
0
0
There's 2 list boxes side by side both with the same range of Years.

As a year in list1 is clicked, can I use its listindex to move list2 to the same year ? Not select it, just bring it into view ?

VS 2010 I seek help about TCP/IP Multiclient server

$
0
0
Hi, thanks in advance por the replies!

I'm a newbie coder, I want to make a small Software like a Chat for multiple clients using Multithreading server of(TCP)

I've studied a lot of examples over internet but I dont understeand how to make one, and when I try to modify these codes I get lost

(The Msdn examples are killing me)

Can Someone tell me how to start?
or teach me (In human terms) the basics of TCP multithreading server?

****What I Know****

Nothing...

Remove Button from Form :Second episode

$
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

Aligned Controls Swapping Place

$
0
0
I have a MDI Form with a StatusBar and PictureBox both Bottom Aligned.

The StatusBar is at the very bottom of the MDI Form and the PictureBox is sitting right above.

The Bottom Aligned PictureBox's height is sizeable by using the mouse to drag it's border making it bigger or smaller.

All works really well unless you start messing around and quickly drag the PictureBox border upwards. Doing this causes the StatusBar and PictureBox to switch places.

The PictureBox jumps to the bottom of the MDI Form and the StatusBar sitting above it.

Is there a way to 'Lock' an Aligned Control such as the StatusBar so that it will always be the lowest docked object?

Thanks.

Excel Automation Errors from VB6

$
0
0
I swear I think Windows 10 is just continuing to take backward steps.

As of some very recent Windows 10 update, I can no longer open XLSM or XLTM files from VB6.

I can't do ...

Code:

Set wbk = xls.workbooks.Add("SomeTemplate.xltm")
... nor ...

Code:

Set wbk = xls.workbooks.Open("SomeExcelFile.xlsm")
The first thing that happens is I get the following, which doesn't have the focus and gets behind my program's open forms, which is exceedingly annoying...

Name:  e1.png
Views: 44
Size:  4.6 KB

Once you find this message and click "Ok", then you get this (in the IDE, but same compiled)...

Name:  e2.png
Views: 33
Size:  4.6 KB

You click "Debug" and it shows you one of those lines like the above. If they're not macro files, all works fine. Also, just FYI, I'm running my Excel fairly wide-open:

Name:  e3.jpg
Views: 37
Size:  24.8 KB

Nothing I do seems to make any difference. I've added the file locations to the "Trusted Locations", and still no go. One thing that does work is to delete all the macros out of the Excel files, and then I can automate them. But this isn't a viable option.

Any Ideas,
Elroy

EDIT1: And just to add another piece, this is code that has literally worked fine for MANY years. We're not talking about new code. And it's been working on Windows 10 until quite recently.

EDIT2: Another piece is that I'm running Excel (Office Pro) 2010 on this machine. It'd take me a bit to set up a more recent version of Excel combined with Win10.
Attached Images
   

VS 2017 Hashing on VB.NET the same way Azure HashBytes Hashes

$
0
0
Hi

Im hashing a password on Azure using the HashBytes Function which is working great, but im having a problem producing the same hash on VB.NET because its using a string where HashBytes uses a Binary variable to hash against.

how can i duplicate whats happening with Hashbytes on VB.NET, the reason i need this is for compatibility and testing purposes.

ill post the code im using on both below

-Azure Code (SQL_transcript - stored procedure)
Code:

DECLARE @UserName VARCHAR(100),
                @Password VARCHAR(64),
                @PasswordSalt VARBINARY(64),
                @CustomerID INT,
                @HashedPassword VARBINARY(64)

BEGIN

--@Params is passed to the SP as a string

SET @UserName = (SELECT [Data] FROM dbo.Split(@Params , '|') WHERE ID = 1)
SET @Password = (SELECT [Data] FROM dbo.Split(@Params , '|') WHERE ID = 2)
SET @CustomerID = (SELECT [Data] FROM dbo.Split(@Params , '|') WHERE ID = 3)

--Create a 64bit random salt to add to the password
--not to interested in checking for duplicate salting in the DB since it would be extremely rare and does not cause an issue anyway
SET @PasswordSalt = CRYPT_GEN_RANDOM(64)

--Hash the salted password to get a 64bit hash
SET @HashedPassword = HASHBYTES('SHA2_512', CONVERT(VARBINARY(100), @Password) + @PasswordSalt)

--Prevent duplicate usernames
IF (NOT EXISTS(SELECT [ID] FROM [dbo].[tblUser] WHERE [UserName] = @Username))
        BEGIN
                INSERT INTO [dbo].[tblUser]
                        ([UserName], [PasswordHash], [PasswordSalt], [CustomerID])
                VALUES
                        (@UserName, @HashedPassword, @PasswordSalt, @CustomerID)
        END

ELSE
        BEGIN
                RETURN 2
        END


-VB.NET Code (this prehashes the password before its sent to the stored procedure)
Code:

Private Sub btnCreate_Click(sender As Object, e As EventArgs) Handles btnCreate.Click
        If Not CheckForm() Then Exit Sub 'this just checks all the fields are filled in properly

        'just a simple salting and hash on this side
        Dim PasswordHash As String = Hash512(txtPassword.Text, txtUserName.Text)
        Dim RetVal As Integer = 0

        RetVal = UpdateRecords_WithStoredProcedureB("SP_Name", "ConString", "SP_VarName", SP_Params)

        If RetVal = 0 Then
            MessageBox.Show("Account Created")
            Me.Close()
        Else
            MessageBox.Show("There was an error creating the account")
        End If

    End Sub

Public Function Hash512(password As String, salt As String) As String
        Dim convertedToBytes As Byte() = Encoding.UTF8.GetBytes(password & salt)
        Dim hashType As HashAlgorithm = New SHA512Managed()
        Dim hashBytes As Byte() = hashType.ComputeHash(convertedToBytes)
        Dim hashedResult As String = Convert.ToBase64String(hashBytes)
        Return hashedResult
    End Function

im hoping to find how to duplicate the procedure from the DB and use it in the VB.NET code.

Thanks.


**********************************EDIT**************************

- i added the function used below the 'btnCreate_Click' event code

VS 2015 Form inside Panel Loading data Problem

$
0
0
Good day. i have these set of codes.

> Main Form where i call the form and placed it to the panel1
Name:  mainform.jpg
Views: 63
Size:  9.4 KB

> this one is the form load of frmuserfile
note : i already tried breakpoints here. and all seems to passed per line.

Name:  formload.jpg
Views: 61
Size:  13.0 KB

> lastly here the class where i fetch data from my database.
NOTE: i have an existing data in each fields. so there should be a display on my datagridview.

Name:  dgv.jpg
Views: 51
Size:  24.3 KB


My problem is that. i have no idea why does not fetching any records at all. frmuserfile is working and fetchign records if i am running it individually. Please help me with this. TIA
Attached Images
   

vb6 Error 429, activeX component can’t create object.

$
0
0
hi, my vb6 project runs fine on win7 32bit pc, but has error 429 when running on win10 64bit pc, .
vb6 Error 429, activeX component can’t create object.
it happens when trying to run this statement Set objProtean = New Protean.CProteanSession; the library "Protean" can’t create object.
open project in notepad, show
Reference=*\G{A8F49161-B9C7-11D1-BBC7-0000C091D9DB}#1.0#0#C:\Program Files (x86)\NEC\FlexProcess ERP Client\bin\protean.DLL#Marcam Protean Automation DLL 'protean.dll'

compared to the working win7 32bit PC, the win10 64bit pc has the library in C:\Program Files (x86)\, instead of C:\Program Files\.
C:\Program Files (x86)\NEC\FlexProcess ERP Client\bin\protean.DLL

compared the registry on win7 & win10, they have same list of entries referring to C:\Program Files (x86)\NEC\FlexProcess ERP Client\bin\protean.DLL , except on win10 has the following extra entries:
1. [HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{1956B3C2-8D4F-11d3-BD3F-00105AE7D160}\InprocServer32]
2. [HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{5FBD2511-9C00-11d1-BBBE-0000C091D9DB}\InprocServer32]
3. [HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{5FBD2514-9C00-11d1-BBBE-0000C091D9DB}\InprocServer32]
4. [HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{CFCD93D4-FC55-11d3-80CB-00C04FA081C5}\InprocServer32]
5. [HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{D7096C4B-C5CB-48e2-86AC-B54F23A1878A}\InprocServer32]
6. [HKEY_CLASSES_ROOT\WOW6432Node\TypeLib\{A8F49161-B9C7-11D1-BBC7-0000C091D9DB}\1.0]
7. [HKEY_CLASSES_ROOT\WOW6432Node\TypeLib\{A8F49161-B9C7-11D1-BBC7-0000C091D9DB}\1.0\0\win32]

any input and help is much appreciated.
jl4r

[RESOLVED] Combobox - change text based on Item selection

$
0
0
Hi,

I have a very strange requirement from users which I can' solve... I have a Textbox and Combobox beside It - whatever Item I select in Combobox, It' Text get's added into Textbox. So the output when selecting 2 Items from Combobox is "John Davies, Mike Burrough". This works fine.

Now what bothers user is design. They don't want to be able to edit in Textbox (that is solved) but also want to look this field same as Combobox only - without Textbox :).

So, the question is : Can I select an Item from binded/nonbinded Combobox and update Combobox.Text to achieve same result ??

This is the code that I use currently (Textbox + binded Combobox solution):

Code:

private void DrawText(TextBox txt, ComboBox cmb)
        {
           
            DataRowView drv = (DataRowView)cmb.Items[cmb.SelectedIndex];
     

            if (string.IsNullOrEmpty(txt.Text))
            {
                txt.Text = cmb.GetItemText(cmb.SelectedItem) + " " + drv["NAME"].ToString();
            }
            else
            {
                txt.Text = txt.Text + " , " + cmb.GetItemText(cmb.SelectedItem) + " " + drv["NAME"].ToString();
            }

        }

        private void Cmb_SelectionChangeCommitted(object sender, EventArgs e)
        {
            ComboBox cmb = (ComboBox)sender;
         
            switch (cmb.Name)
            {
                case "Combobox1":
                    DrawText(Textbox1, cmb);
                    break;

                //... and so on
            }

        }

I know It's a weird question, but maybe It can be done, so thanks for help in advance !

VS 2015 Excel Sum not working after import from vb.net

$
0
0
Hi

I am using VS 2015 and Office 2010

I have a code in VB.NET that exporting a listview to excel.
The export complete just fine and the excel sheet look OK.

The problem is that when I go to the end of a column
I can't use the SUM() function of the excel.
No matter what I do inside sheet Sum returns always zero.

If I edit one or more of the cells in the column I want to summarize
then the Sum() working fine. just pressing F2 and Enter in the cells.

What I am doing wrong?

Here the code I am using.

Code:

Dim ExcelApp As Object
Dim ExcelBook As Object
Dim ExcelSheet As Object
Dim i As Integer
Dim j As Integer
Dim m As Integer
'create object of excel
ExcelApp = CreateObject("Excel.Application")
ExcelBook = ExcelApp.WorkBooks.Add
ExcelSheet = ExcelBook.WorkSheets(1)
ExcelSheet.visible = True

With ExcelSheet
    'fill excel with values
    For m = 0 To LST.Columns.Count - 2
        .cells(1, m + 1) = LST.Columns(m).Text
    Next
    For i = 1 To LST.Items.Count - 2
        If IsNumeric(LST.Items(i - 1).Text) Then
            .cells(i + 1, 1) = String.Format("{0:n2}", Decimal.Parse(LST.Items(i - 1).Text))
            .cells(i + 1, 1).NumberFormat = "0.00"
        Else
            .cells(i + 1, 1) = LST.Items(i - 1).Text
        End If
        For j = 1 To LST.Columns.Count - 2
            If IsNumeric(LST.Items(i - 1).SubItems(j).Text) Then
                ' Check for the Code field, do not to print decimals
                If j = 1 Then
                    .cells(i + 1, j + 1) = LST.Items(i - 1).SubItems(j).Text
                Else
                    .cells(i + 1, j + 1) = String.Format("{0:n2}", Decimal.Parse(LST.Items(i - 1).SubItems(j).Text))
                    .cells(i + 1, j + 1).NumberFormat = "0.00"
                End If
            Else
                .cells(i + 1, j + 1) = LST.Items(i - 1).SubItems(j).Text
            End If
        Next
    Next
End With

Thank you for your help

Which Windows DLL actually has RtlCopyMemory?

$
0
0
According to MSDN, RtlCopyMemory is faster than RtlMoveMemory (though RtlMoveMemory is often aliased as CopyMemory in VB6 declarations). So I scrolled down the MSDN page and found where it says what DLL to find it in. And there I see it say "NtDll.dll (user mode)", so I know what DLL it should be in, and I use this declare statement:
Code:

Private Declare Sub RtlCopyMemory Lib "ntdll.dll" (ByRef Destination As Long, ByRef Source As Long, ByVal Length As Long)
Unfortunately this doesn't work when I actually call the DLL function in my test program:
Code:

Private Sub Form_Load()
    Dim a As Long
    Dim b As Long
    a = 5
    RtlCopyMemory b, a, 1
    Print b
End Sub

I end up getting an error that says "Can't find DLL entry point RtlCopyMemory in ntdll.dll". So which DLL is it in? There's tons of DLL files in the Windows system folder. And it's not like it's an undocumented function either. It's documented on MSDN, so if MS moves its location, then there's going to be a lot of programs out there that use it that will now break.

Here's the MSDN page for it https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

[RESOLVED] Change Combobox Style

$
0
0
Hi Guys
How can i change the combobox without property ;
I need change it by code in run time
As combobox1.Style=2 ?

Saveas workbook from another workbook

$
0
0
Hi Experts

I have two Excel files, one file is have Macro. and another one is .xlsx file.
I'm trying to Saveas the xlsx file to specific folder path from xlsm file (macro is run from file only)

I have record a Macro but it's not working, when i run this macro i got error like below.
Name:  saveas error.png
Views: 23
Size:  2.7 KB
This is my code:

Code:

Sub sveas_Workbook()
    Application.WindowState = xlNormal
    Windows("Master file.xlsx").Activate
    ChDir "C\:Documents and Settings\New Folder\Saved files"
    ActiveWorkbook.SaveAs Filename:= _
        "C\:Documents and Settings\New Folder\Saved files\" & Range("BC20").Value & "\" & Range("BD26").Value & "\" & Range("C14").Value & "\" & Range("BC30").Value _
        , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWindow.Close
End Sub

These ranges getting from XLSM file
Code:

Range("BC20").Value & "\" & Range("BD26").Value & "\" & Range("C14").Value & "\" & Range("BC30").Value
Can Anyone Help me Please

Thanks in advance
Attached Images
 

XML Parser (written entirely on VB6)

$
0
0
Originally written by: Jason Thorn (Fork by Alex Dragokas)

There are 2 projects:

1) GUI
(activeX dll based)
compile vbXml-browser\Browser\Browser.vbg
Required: MSCOMCTL.OCX

2) Simple app (debug. window sample)
vbXml-simple\Project1.vbp

Some xml files samples are in 'xml-files' dir.

Classes allows to:
- read .XML files
- append nodes / attributes
- serialize back to .xml

Supported:
- all required special characters
- CDATA markup
- UTF-16 LE XML files format (however, it will be converted to ANSI)
- XML header
- reading tags' attributes

Currently not supported:
- Entities

P.S. There maybe some trouble with compilation GUI (vbg) caused by binary incompatibility. Maybe, someone help me to set project correctly.

PPS. Classes are not well tested. I'll be glag to get feedback.

Name:  title.jpg
Views: 67
Size:  23.7 KB

Feel free to use,
Good luck :)
Attached Images
 
Attached Files

VS 2017 Need help with school.....

$
0
0
Hello,

I need to put the periodic table into a multi-value array with symbol abbreviation and atomic number for each element. I need to then prompt for an element input, when submitted, I must print out all the other elements in the same column as the element that was input by the user.

Any and all help is appreciated.
Thanks.

Error "Object reference not set to an instance of an object."

$
0
0
Hi all,

I'm using the following code to read data from a DataGridView row. It works fine.

Code:

Private Sub dgvGamesList_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvGamesList.CellClick

I = dgvGamesList.CurrentRow.Index

'...... READ DATA FROM THIS ROW
'...........

End Sub

However, for this code to work you need to click each row with your mouse. It won't work if you select the rows using the arrow keys. So, I tested the following code, but I got the "Object reference not set to an instance of an object." error. The error is pointed to the line "I = dgvGamesList.CurrentRow.Index"

Code:

Private Sub dgvGamesList_RowEnter(sender As Object, e As DataGridViewCellEventArgs) Handles dgvGamesList.RowEnter

I = dgvGamesList.CurrentRow.Index

'...... READ DATA FROM THIS ROW
'...........

End Sub

How can I run my script using the "CurrentRow.Index", so that it works whenever a row is highlighted? Any help is greatly appreciated.

Thanks,

Robert

Sum of sum of groups

$
0
0
WHY IT RETURNS 0 WHEN I CREATE A FORMULA FIELD IN CRYSTAL REPORT?

CODE:
Code:

if {Consumption_Branch;1.CLASSIFICATION}="CHILLED"  then
if {Consumption_Branch;1.Vatable}=True then
global numbervar GTotal:=GTotal + Sum ({Consumption_Branch;1.TOTALCOST}, {Consumption_Branch;1.UOM})/1.12
else
global numbervar GTotal:=GTotal + Sum ({Consumption_Branch;1.TOTALCOST}, {Consumption_Branch;1.UOM})

I group my report by classification and sum its total total cost per item but i want to sum the total cost per classification with the code above that calculates items with and without vat..

"conditional" dim type

$
0
0
Hello All.

I have a procedure I call from 2 different areas in my app/

The procedure does the same thing for both situations, but in one case must have one of its internal variables declared as type A and in the other case the same variable must be declared as type B.

So, the following obviously does not work, I am aware that you can not do a Dim inside and if statement. This is where I need a solution. A non-declared variable would work, but i like it better for 'clean' & ease programming and intellisense.

Code:

Public Sub FillHistoryGrid(ByRef TempmyVar)
      If condition = true Then
          Dim myVar As New List(Of Type5)
      Else
          Dim myVar As New List(Of Type6)
      End If

      myVar = TempmyVar

      ...
end sub

Any ideas?

Thanks for all your help!

An app like Letgo

$
0
0
Actually, how much does an app like Letgo cost? I understand that it's not easy question but I want to know approximate cost :)
Viewing all 42299 articles
Browse latest View live


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