Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all 27407 articles
Browse latest View live

Equivalent password hash function for vb.net

$
0
0
In my web application, before insert password in db, I create a random salt, and later I pass this salt to an hash function, like this:

Code:

function generate_salt()
{
  $max_length = 100;
  $salt = hash('sha256', (uniqid(rand(), true)));
  return substr($salt, 0, $max_length);
}

function hash_password($salt, $password)
{
    $half = (int)(strlen($salt) / 2);
    $hash = hash('sha256', substr($salt, 0, $half ) . $password . substr($salt, $half));

    for ($i = 0; $i < 100000; $i++)
    {
        $hash = hash('sha256', $hash);
    }

    return $hash;
}

salt: e02017446d08af19925df8836c49a0626f65718ace542db7c5593de7a3c34024
hash: d2f36c5a8e86d7893b8a4e16028ec0fd95748e18b9625087acc61545f6cb1df8

This is my vb.net function:

Code:

Public Shared Function CreateRandomSalt() As String

    Dim mix As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+=][}{<>"
    Dim salt As String = ""
    Dim rnd As New Random
    Dim sb As New StringBuilder

    For i As Integer = 1 To 100 'Lunghezza del salt
        Dim x As Integer = rnd.Next(0, mix.Length - 1)
        salt &= (mix.Substring(x, 1))
    Next

    Return salt

End Function

Public Shared 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

salt: Y&1oY)g)u}2P%RD%Z+ou1d1LTnc<Ik#6bgR9r]6E$]{{4<6^4x)0DG^]PpV$qh!KN]&h<WXePk96f2jT8oWnsL3UsWtB1+pgM&$8
hash: oh6wErU5dPdgXugmQcGX8Mt1pXomImpKxJvePCvr9k9L5bXQiyod3kLUNnzmJ6O4lRHivIoWQXNKSSbRQQhSGQ==

Now my problem's that when I create a new user or update a password for a specific user from my vb.net app, the web application can't execute the login to my user, maybe the password encoding is diffent, so I need a function for vb.net or php that allow me to have the same encoding. How I can do that?

VS 2015 Integrating with Coreldraw - Newbie question

$
0
0
Good morning. Literally today I have just moved to VS after too long holding on to VB6 !
As a first play I am trying to automate opening of templates in Coreldraw, selecting the font and resizing the text after manipulating data to determine what template to open.

I have managed the first part and can select and open the template but am now at a loss how to select teh font and change the font size.

Any help would really be appreciated.

Basic multithreading help

$
0
0
Im trying to make a label update with sequential ellipsis when im running a stored procedure. However, the UI thread still locks up. Not sure what im doing, first time doing multithreading.

Heres the code

Button Click
Code:

Private Sub btnBilcourtClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBilcourt.Click
        isTaskRunning = True
        Dim t1 As New Threading.Thread(AddressOf Count)
        t1.IsBackground = True
        t1.Start(100)
        lblTaskRunning.Visible = True
        bil1()
        bil2()
    End Sub

Threading code
Code:

Private Sub Count(ByVal Max As Integer)
        Dim ellipsis As String = ""

        Do While isTaskRunning = True
            For i = 0 To 4
                If (i = 0) Then ellipsis = ""
                If (i = 1) Then ellipsis = "."
                If (i = 2) Then ellipsis = ".."
                If (i = 3) Then ellipsis = "..."
                SetLabelText("Task is running" & ellipsis)
                Threading.Thread.Sleep(400)
            Next
        Loop
    End Sub
    Private Sub SetLabelText(ByVal text As String)
        If lblTaskRunning.InvokeRequired Then
            lblTaskRunning.Invoke(New Action(Of String)(AddressOf SetLabelText), text)
        Else
            lblTaskRunning.Text = text
        End If
    End Sub

VS 2015 Obtaining a combo box selection in order to execute a sub.

$
0
0
Hello all,
I have attempted to find this answer elsewhere on the forums but havent been able to or haven't understood.

Background:
I'm a 2nd year mechanical engineering student with a requirement of a programming course. I have never coded before so my ability level is very basic, however we have been tasked to create a GUI to complete an engineering calculation. So far I have managed to create a basic conversion for metric and imperial however I am struggling to make my selection work.

Issue:
Have combo box with 4 selectable items. Meters, millimetres, inch & feet.
Upon selection of each I wish to have a sub program run for their different conversions. However I can not get the sub to run as I am unable to obtain the value from the combo box in order to execute the sub.
Please help

Code:

Public Class Form1
    Dim metrevalue As Double
    Dim millvalue As Double
    Dim inchvalue As Double
    Dim feetvalue As Double

    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs)

    End Sub

    Private Sub CmdLgthCalc_Click(sender As Object, e As EventArgs) Handles CmdLgthCalc.Click




        '' ###### Run sanitiy check on inputs make sure is only numbers.
        If TxtLgthInput.Text = "" Or Val(TxtLgthInput.Text) = 0 Then
            MsgBox("Please enter a Numerical value in the unit to convert box", MsgBoxStyle.Exclamation, "Missing Data")
        ElseIf CboLghtMeas.Text = "Select Unit" Then
            MsgBox("Please select a Unit of Measurment from the list", MsgBoxStyle.Exclamation, "Missing Data")
        End If

        If CboLghtMeas.Text = "Metres(m)" Then

            Metres()

        ElseIf CboLghtMeas.Text = "Millimetre(mm)" Then
            Millimeters()

        ElseIf CboLghtMeas.Text = "Inches(in)" Then
            Inches()

        ElseIf CboLghtMeas.Text = "Feet (ft)" Then
            Feet()


        End If


        TxtMtr.Text = metrevalue
        TxtMill.Text = millvalue
        TxtInch.Text = inchvalue
        TxtFt.Text = feetvalue


    End Sub

   
    Public Sub Metres()

        metrevalue = Val(TxtLgthInput.Text) * 1
        millvalue = Val(TxtLgthInput.Text) * (10 ^ -3)
        inchvalue = Val(TxtLgthInput.Text) * 0.0254
        feetvalue = Val(TxtLgthInput.Text) * 0.3048
        MsgBox("this far")



    End Sub

VS 2015 Inherits and Overrides

$
0
0
I hope someone could explain what I'm doing wrong with my class experiments today!

I have a class that inherits a text box. I have successfully written several procedures in this class that override the base text box class, however I'm having a problem with OnMouseHover.

If I: Protected Overrides Sub OnMouseHover
I'm told - cannot be declared 'Overrides' becuase it does not override a sub in a base class

But, if I: Protected Sub OnMouseOver
I'm told - shadows an overridable method in the base class Control. To override the base method, this method must be declared 'Overrides'

However, another sub such as: Protected Overrides Sub OnKeyPress
Is perfectly fine.


If anyone knows what I'm missing could you please let me know, or is this another thing not working yet in VB2015. I think I'm starting to go slightly mad!

Thanks.

VS 2012 How to find and click inner html

$
0
0
Hi.

I used this code :

For Each element As HtmlElement In wb.Document.GetElementsByTagName("input")
If element.GetAttribute("type") = "submit" Then
element.InvokeMember("click")
End If
Next

but i want to search in inner html and click on it. what should i do ?

using the resource manager with pictures

$
0
0
Hi,
Trying to pull from a compiled .resource file to put a background in. Here is what I have so far and something is really wrong.
Code:

Dim manager As New ResourceManager(GetType(About))
            Me.PictureBox1.BackgroundImage = CType(manager.GetObject("PictureBox1.BackgroundImage"), Image)

The file is names namespace.About.resources
I get an error saying manager is not defined.

A little help please. Also is that the correct way to turn that stream into a image?

VS 2012 [RESOLVED] Connecting with MSSQL gives error "The connection has been disabled"

$
0
0
Hi! So I have this weird error in my application which I cannot solve for quite a while now..

Intro:
My application will be running on a tablet using celluar network for its data connection with a remote Microsoft SQL server. When the application starts it checks for an available internet connection using a public function called "GetInternetConnection". This will return either True or False and saves the last attempt to my.settings.IsConnected. Everytime a connection is required this function is called and when no internet acces is available it will show a dialog with a message that the user must connect to the internet. A retry button on that dialog does the check again and if it then succeeds it will continue on to the actual code where the connection with internet is required.

- The first form that is loaded has a menubar with one button named "Checklists"
- The form has a sub that loads a specified usercontrol and displays it inside the mainform
- Everytime the user presses a button the "GetInternetConnection" function is called and must be valid to be able to continue


Problem:

Scenario 1 (Internet available):
Application runs fine, no errors

Scenario 2 (Internet available on startup but internet cable removed after loading):
Step 1: Run application; no problems
Step 2: Press button "Checklists"
Step 3: Function to check internet connection is called and fails because cable is removed
Step 4: Internet cable is put back in pc
Step 5: Retry button is pressed and the check internet function is called again and passes.
Step 6: The usercontrol "Checklists" is loaded and shown in the mainform
Step 7: Unplug Internet cable
Step 8: Do something that requires internet in that usercontrol
Step 9: Function to check internet connection is called and fails because cable is removed
Step 10: Internet cable is put back in pc
Step 11: Retry button is pressed and the check internet function is called again and passes.
Step 12: Code is executed which requires internet and it an error occurs "The connection has been disabled"

Scenario 3 (Internet available on startup but internet cable removed after loading):
Step 1: Run application; no problems
Step 2: Unplug internet cable
Step 3: Press the button "Checklists"
Step 4: Function to check internet connection is called and fails because cable is removed
Step 5: Internet cable is put back in pc
Step 6: Retry button is pressed and the check internet function is called again and passes.
Step 7: Usercontrol "Checklists" is loaded succesfully; no errors

Remarks:


So my question is.. Why do I get the "The connection is disabled" error in scenario 2 but not in scenario 3 (and first part of scenario 2). its the same code and same check? Im going mad haha




Source code for CheckInternetConnection:

Code:

    Public Function GetInternetConnection() As Boolean
        My.Settings.IsConnected = False
       
        Try
            My.Settings.IsConnected = My.Computer.Network.Ping("www.digitaalwachtboek.nl", 5000)
        Catch ex As Exception
            My.Settings.IsConnected = False
        End Try
       
        Return My.Settings.IsConnected
    End Function


Source code for mainform:


Code:

    Private Enum LoadControl As Integer
        Dashboard = -1
        Conf_Checklists = 0

    End Enum

    Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
        DisplayControl(LoadControl.Conf_Checklists)
    End Sub
   
    Private Sub DisplayControl(CT As LoadControl)

re:
        GetInternetConnection()

        If My.Settings.IsConnected = False Then

            Select Case CdS_OSN_Controller1.OSN_ShowRibbon(CDS_OSN.CDS_OSN_Controller.OSN_Types.RetryAbort, Color.SkyBlue, "Verbinding met internet", "Maak eerst verbinding met het internet om verder te gaan").ToUpper
                Case "ABORT"
                    Application.Exit()
                Case Else

                    GoTo re
            End Select
        End If
         
        ProgressPanel1.Visible = True
        Refresh()
        Application.DoEvents()

        PanelControl_Master.Controls.Clear()

        Select Case CT
            Case LoadControl.Conf_Checklists
                LabelControl1.Text = "Checklist overzicht"

                Dim p As New CONF_Checklists

                With p
                    .Dock = DockStyle.Fill
                    .boot()
                End With

                PanelControl_Master.Controls.Add(p)

            Case LoadControl.Dashboard
                LabelControl1.Text = "Dashboard"

                Dim p As New DashboardPage

                With p
                    .Dock = DockStyle.Fill
                    .boot()
                End With

                PanelControl_Master.Controls.Add(p)
        End Select

        ProgressPanel1.Visible = False
    End Sub

    Private Sub Dashboard_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        Application.Exit()
    End Sub

    Private Sub Dashboard_Load(sender As Object, e As EventArgs) Handles Me.Load
 
        DisplayControl(LoadControl.Dashboard)
     
    End Sub


Source code for Checklists usercontrol:

Code:

Public Class CONF_Checklists
   
    Private Sub Edit()
 
re:

        GetInternetConnection()

        If My.Settings.IsConnected = False Then


            Select Case Dashboard.CdS_OSN_Controller1.OSN_ShowRibbon(CDS_OSN.CDS_OSN_Controller.OSN_Types.RetryAbort, Color.SkyBlue, "Verbinding met internet", "Maak eerst verbinding met het internet om verder te gaan").ToUpper
                Case "ABORT"
                    Application.Exit()
                Case Else
                    GoTo re
            End Select
        End If


        Dim tempid As Guid = Nothing

        Try

            tempid = CType(GridView1.GetFocusedRowCellValue("P_ID"), Guid)

        Catch ex As Exception
            Exit Sub
        End Try

        If tempid <> Nothing Then

            Dim p As New DLG_New_Checklist

            With p
                .PROP_IsExisting = True
                .PROP_ExistingID = tempid
            End With

            If p.ShowDialog = DialogResult.OK Then

                boot()

            End If

        End If

    End Sub

    Public Sub boot()

        Using Connection As OdbcConnection = New OdbcConnection(My.Settings.DSN)
            Dim odbcCommand As OdbcCommand = New OdbcCommand("SELECT  P_ID, ChecklistName, ChecklistDescription, ModifiedBy, Modified, ChecklistNamedType  FROM dbo.CMS3_CHECKLISTS ORDER BY ChecklistName", Connection) With {.CommandType = CommandType.Text}

            Using TekstveldAdapter As OdbcDataAdapter = New OdbcDataAdapter()
                TekstveldAdapter.TableMappings.Add("Table", "Tekstveld")
                TekstveldAdapter.SelectCommand = odbcCommand
                Connection.Open()

                Using dataSet As DataSet = New DataSet("Tekstveld")
                    TekstveldAdapter.Fill(dataSet)

                    GridControl1.DataSource = dataSet.Tables(0)

                End Using

            End Using

        End Using

        With GridView1
            .Columns("P_ID").Caption = "ID"
            .Columns("P_ID").Visible = False
            .Columns("ChecklistName").Caption = "Titel"
            .Columns("ChecklistDescription").Caption = "Omschrijving"
            .Columns("ModifiedBy").Caption = "Door"
            .Columns("Modified").Caption = "Gewijzigd"
            .Columns("ChecklistNamedType").Caption = "Type"
            .Columns("ChecklistNamedType").Group()

            .ExpandAllGroups()
        End With
       
    End Sub

    Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick

        Dim p As New DLG_New_Checklist

        With p
            .PROP_IsExisting = False
            .PROP_ExistingID = Nothing
        End With

        If p.ShowDialog = DialogResult.OK Then
            boot()
        End If

    End Sub

    Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
        Edit()
    End Sub

    Private Sub GridView1_DoubleClick(sender As Object, e As EventArgs) Handles GridView1.DoubleClick
        Edit()
    End Sub

    Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick
        Dim tempid As Guid = Nothing

        Try

            tempid = CType(GridView1.GetFocusedRowCellValue("P_ID"), Guid)

        Catch ex As Exception
            Exit Try
        End Try



        If tempid <> Nothing Then
 
            Dim p As New CONF_Questions

            With p
                .PROP_ChecklistID = tempid
                .boot()
                .Dock = DockStyle.Fill
            End With

            Dashboard.PanelControl_Master.Controls.Add(p)
            p.BringToFront()

        End If
       
    End Sub

    Private Sub CONF_Checklists_ControlRemoved(sender As Object, e As ControlEventArgs) Handles Me.ControlRemoved
        boot()
    End Sub
End Class


Capture Start Button Event in Windows

$
0
0
Hi All,

I'm creating a Start Menu replacement for Windows and need to capture the Start button event, can anyone help?

I can disable the button and hide it but am struggling to capture events.

thanks in advance
Darren

[RESOLVED] Connecting with MSSQL gives error "The connection has been disabled"

$
0
0
Ignore this post. I tried deleting it but I cannot . It is a short version of another post of which I thought failed to post. Sorry!!


Hi, I need some help or suggestions with an application that requires internet.

I have a tablet that runs my application using the celluar network for internet connection and connection to my MSSQLExpress database.

I have tried the following code to check for internet connection. This (seems to) work(s).

Code:

  Public Function GetInternetConnection() As Boolean
        My.Settings.IsConnected = False
       
        Try
            My.Settings.IsConnected = My.Computer.Network.Ping("www.google.com")
        Catch ex As Exception
            My.Settings.IsConnected = False
        End Try
       
        Return My.Settings.IsConnected
    End Function

This code is always executed before executing any code with a query in it. If the function above returns false then a message is shown that internet must be restored before continueing. If internet is restored the function is called again to check.

The code that is executed before a piece of code is executed which requires internet:

Code:

re:

        GetInternetConnection()

        If My.Settings.IsConnected = False Then
 
            Select Case Dashboard.CdS_OSN_Controller1.OSN_ShowRibbon(CDS_OSN.CDS_OSN_Controller.OSN_Types.RetryAbort, Color.SkyBlue, "Verbinding met internet", "Maak eerst verbinding met het internet om verder te gaan").ToUpper
                Case "ABORT"
                    Application.Exit()
                Case Else
                    GoTo re
            End Select

        End If


This works fine except in one case:

1: I unplug internet cable
2: I press a button to open a new dialog where the internet check function is called
3: The function returns False and shows my dialog prompting for internet required
4: I plug the cable back in and press "retry"
5: The code returns to "re:" to check the connection again
6: The function is called again and return True
7: The program executes the query that comes after the check and FAILS.

When I do the steps above without removing the internet cable everything works fine.

The error I get is:

"The connection is disabled"


I really really hope any could help me out, I'm going insane here ;)

VS 2012 Media Player control Random/Shuffle .wav files from Resource folder

$
0
0
Hi new to this forum & fairly new to Vb & coding so apologies if worded incorrect.

So I am looking to create a audio media player with functions:
Play/stop on one button
Random/shuffle set as default on (playing up to 1000+ .wav files)
use Bass.dll for audio effects

I have added mdsxm.osc control to toolbox (media player) & using
Code:

My.Computer.Audio.Play(My.Resources.audio1_, _AudioPlayMode.Background)
My.Computer.Audio.Play(My.Resources.audio2_, _AudioPlayMode.Background)

& files play in numerical order but looking to shuffle.
If there is an easier method I would be very grateful as I need to add up to 1000 wav file names.

Thanks in advance :thumb:

Refreshing task bar icon

$
0
0
Hello all,
I've created an ETL program, and it works fine. as I have a number of these on the same server, I have them minimised.

When there is a problem, I have the icon change to a warning, but I can't see these when the program is minimised, and the task bar doesn't refresh.


Code:

' on error change the icon
 Me.Icon = New Icon("C:\Icons\faviconHSFAIL.ico")


Can anyone suggest how I can refresh the task bar from within my program so I can see the warning icon?


Thanks in advance

Dave

VS 2013 TableLayoutPanel Does not resize properly

$
0
0
I swear I will blow my brains out over the stinking TLP control.
All I am trying to do is create a home for four equally spaced buttons at the top of a panel.

First I try percentage. 25, 25, 25, 25. Nope nothing adjusts.

Next 25, 25, 25, autofill. Nope.

Total space is 480 pixels. Made it absolute.
120, 120, 120, 120. Nope.
120, 120, 120, autofill. Nope.

Dropping buttons into the slots can crap out also, either it forces the button into slot one or it centers them in the control ignoring the slots.

Set buttons to dock.fill and you cannot move them. without dock.fill they are the wrong size.

This is the experience I have had with the control since version 2010.
What am I missing about using this control.
I've looked up tutorials on its use and I cannot get it to do what they suggest it can do.

Is my only recourse to write my own TLP or use a toolstrip?

Gripe, gripe, gripe...

How do I create a physical collision between objects

$
0
0
I would like to know how I can create a phyical colliion between the player PictureBox and obtacle picture boxes so that you can walk into it or jump onto it. I would like to be able to store each obstacle into an array o I can call up each obstacle as one. E.g. If picPlayer.Bounds.IntersectsWith(picObstacles) Then etc.

Here is the code so far for the game.

Code:

Public Class Form1
    Dim blnJump As Boolean = True

'I TRIED TO MAKE AN ARRAY INCLUDING TWO OBJECT,THE GRASS AND THE ANOTHER PICTUREBOX
    Dim picOBJ() As PictureBox = New PictureBox() {picGrass, PictureBox2}


    'Will Control the key functions and activate asociated timers
    Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown

        Select Case e.KeyCode
            Case Keys.Right
                tmrRight.Enabled = True
                tmrLeft.Enabled = False
            Case Keys.Left
                tmrLeft.Enabled = True
                tmrRight.Enabled = False
            Case Keys.Up
                If blnJump = True Then
                    tmrUp.Enabled = True
                    blnJump = False
                    x = 0
                End If
        End Select

    End Sub


    Private Sub Form1_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp

        Select Case e.KeyCode
            Case Keys.Right
                tmrRight.Enabled = False
            Case Keys.Left
                tmrLeft.Enabled = False

        End Select

    End Sub

    'Controls move left timer
    Private Sub tmrLeft_Tick(sender As Object, e As EventArgs) Handles tmrLeft.Tick
        picPlayer.Left = picPlayer.Left - 3

    End Sub

    'Controls move right timer
    Private Sub tmrRight_Tick(sender As Object, e As EventArgs) Handles tmrRight.Tick
        picPlayer.Left = picPlayer.Left + 3

    End Sub

    Private x As Integer = 0
    'Controls Jump timer
    Private Sub tmrUp_Tick(sender As Object, e As EventArgs) Handles tmrUp.Tick

        If x < 20 Then
            picPlayer.Top -= 6
        Else
            tmrUp.Enabled = False
            tmrDown.Enabled = True
        End If
        x += 1
    End Sub

    'Controls fall/move down timer
    Private Sub tmrDown_Tick(sender As Object, e As EventArgs) Handles tmrDown.Tick

        'For Each obstacle In picOBJ
        '    obstacle = obstacle
        'Next

        picPlayer.Top += 6

        If picPlayer.Bounds.IntersectsWith(picGround.Bounds) Then
            blnJump = True
            tmrDown.Enabled = False
        End If

    End Sub

End Class

Thanks in advance! VB begginner here if you hadn't noticed by the sloppy code already :)

VS 2013 Lock keyboard?

$
0
0
I'm trying to create a form where the keyboard keys can be pressed and they show a result on the form

but, I need to lock the Windows environment, for instance, if the F1 key is pressed, I need Windows OS to not respond. (I hope that makes sense?)

Can this be achieved?

vb2005 - Datagridcell commit change

$
0
0
Hello

I have a datagridview on a from that is bound to an underlying datasource.
I have a save control (button) on the form that when clicked will perform some validation checks and also iterate through each row of the datagridview and calculate the sum of a particular column (amount column).

My issue is as follows;

If I make a change to the "amount column" of a datagridrow - then click into another field (i.e. lose focus from the "amount column" datagridcell) - and then click the save control, everything works as expected and the sum of the "amount column" is calculated correctly.

If I make a change to the "amount column" of a datagridrow and then immediately click the save control, it calculates based on the previous value of the amount field.

i.e. the value I updated is not used when I iterate the datagridrows and calculate the sum of the amount fields.

As a work around I can make my save control change focus to another field and then perform the calculation which works - but I am wondering if there is a "better" way to do this.

[RESOLVED] Could someone explain For Next statement?

$
0
0
I am confused with For Next. What does it do, how does it work and maybe an exmaple. I think I need it to iterate through my array of Pictureboxes so that player doesnt collide with them

FTP DL mysteriously fails

$
0
0
Been using a program for about a half a year I developed in VB.Net VisualStudio 10

One thing it does is goes to my web domain and downloads a small text file.

A couple months or so ago it quit working. It will download about 3/4 of the text file, then pause, then time out.

I use FTP and have the user name and passcode hard coded into the program. I can download from the web domain using the cPanel that GoDaddy offers successfully.

I wonder if Microsoft updated the compiler so something changed that is causing this to fail.

My program is useless with this issue.

Any ideas?

Thanks in advance! :)

VS 2010 The underlying connection was closed: Could not establish trust relationship for the

$
0
0
Hello,

i get the problem to access https.. first error is "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel." then i add this "ServicePointManager.ServerCertificateValidationCallback =" code from googling but get another error at Dim dataStream As Stream = request.GetRequestStream() '<<--error "The underlying connection was closed: An unexpected error occurred on a receive."

here is my code pleas help :confused::confused::confused:

Public Function HttpWebRequestHelper(ByVal URL As String, ByVal Username As String, ByVal Password As String, ByVal Data As String) As String

'try this but error "The underlying connection was closed: An unexpected error occurred on a receive."
'ServicePointManager.ServerCertificateValidationCallback = (Function(sender, certificate, chain, sslPolicyErrors) True)
'try this but error "The underlying connection was closed: An unexpected error occurred on a receive."
'ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(Function() True)
'try this but error "The underlying connection was closed: An unexpected error occurred on a receive."
ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf CertificateValidationCallBack)

Dim request As HttpWebRequest = HttpWebRequest.Create(URL)
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(Data)
Dim authInfo As String = Username & ":" & Password

' prepare request object
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo))
request.Headers.Add("Authorization", String.Format("Basic {0}", authInfo))
request.Credentials = New NetworkCredential(Username, Password)
request.AllowAutoRedirect = True
request.Method = WebRequestMethods.Http.Post
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length

' Get the request stream and write data to it
Dim dataStream As Stream = request.GetRequestStream() '<<--error "The underlying connection was closed: An unexpected error occurred on a receive."
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()

' Get the response read content returned by the server.
Dim response As HttpWebResponse = request.GetResponse()

'get json
Dim jsonString As String = String.Empty
Using sreader As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
jsonString = sreader.ReadToEnd()
End Using
Dim jsSerializer As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer()
Dim jss = New JavaScriptSerializer()
Dim sLogin = jss.Deserialize(Of Object)(jsonString)
stoken = sLogin("access_token")

End Function



Thanks

array as a private object with a type specifier

$
0
0
I know I am just missing something easy with this one, but the MSN documentation was bland on the subject at best.

I have an array declared in my fields. Something is wrong with the way it has the bounds. Looking through all the examples I found with search none really had anything like this. I am translating 1.0 to 2.0 to get things to work on win 7.

Code:

Private DescList As String(0 To ., 0 To .)
I thought about doing something like this, but it really does not account for the 0- infinate
Private DescList(,) As String
Viewing all 27407 articles
Browse latest View live


Latest Images

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