Click here to Skip to main content
15,887,596 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionHow to increase row height in list view vb.net 2008 Pin
D.Manivelan24-Apr-14 23:06
D.Manivelan24-Apr-14 23:06 
QuestionThird Party Software/ OCX grammar checker for VB 6.0 Pin
radjitz24-Apr-14 22:00
radjitz24-Apr-14 22:00 
AnswerRe: Third Party Software/ OCX grammar checker for VB 6.0 Pin
CHill6025-Apr-14 0:47
mveCHill6025-Apr-14 0:47 
QuestionChanging backcolor of a textbox Pin
CHill6024-Apr-14 5:54
mveCHill6024-Apr-14 5:54 
AnswerRe: Changing backcolor of a textbox Pin
Tino Fourie24-Apr-14 6:16
Tino Fourie24-Apr-14 6:16 
GeneralRe: Changing backcolor of a textbox Pin
CHill6025-Apr-14 0:45
mveCHill6025-Apr-14 0:45 
AnswerRe: Changing backcolor of a textbox Pin
Richard Deeming24-Apr-14 6:21
mveRichard Deeming24-Apr-14 6:21 
QuestionAccessing an external DLL from a Timer - should there be a problem? Pin
Peter R. Fletcher23-Apr-14 11:39
Peter R. Fletcher23-Apr-14 11:39 
I want to download data every five minutes from a Davis Weather Station. The code that actually talks to the hardware is in a DLL, and I don't have access to the source (or to terribly good documentation, sadly!). My code that does the downloading (below) works reliably and without problems if called in the normal way. If it is called from a System.Timer OnElapsed thread, the program (run in Debug mode) crashes immediately without reporting what is going wrong. The variables and structures starting with g are defined outside any Functions in a Module, so they have global scope, as do WSInitialized and USBSerialNumber. I think that everything else is fairly obvious. Commenting out the one line which retrieves text data into a StringBuilder seems to fix the problem, and I can do without that data, but I would like to know what is going on, since I may want to do something in the future where the use of StringBuilders to receive data (if that is what is causing the problem) is less optional.
VB
Private Sub Get_Davis_WeatherData(ByRef gwdcurrent As WeatherData)
    Dim dtsTemp As New DateTimeStamp
    Dim sbWindDir As New StringBuilder(5)
    If Not WSInitialized Then
        CloseUSBPort_V()
        USBSerialNumber = GetUSBDevSerialNumber_V()
        If (OpenUSBPort_V(USBSerialNumber) = 0) Then
            If (InitStation_V() = COM_ERROR) Then
                MsgBox("Cannot initialize the USB port for the Weather Station")
                Exit Sub
            Else
                SetCommTimeoutVal_V(100, 100)
                WSInitialized = True
            End If
        Else
            MsgBox("Cannot open the USB port for the Weather Station")
            Exit Sub
        End If
    End If
    If (GetStationTime_V(dtsTemp) = 0) Then gwdcurrent.Time = DateStamp2UnixTime(dtsTemp)
    If LoadCurrentVantageData_V() = 0 Then
        gwdcurrent.OutTempF = GetOutsideTemp_V()
        gwdcurrent.OutHum = GetOutsideHumidity_V()
        gwdcurrent.BPressure = GetBarometer_V()
        gwdcurrent.WindChillF = GetWindChill_V()
        gwdcurrent.DewPointF = GetDewPt_V()
        gwdcurrent.RainTotal = GetTotalRain_V()
        gwdcurrent.Rain24h = GetDailyRain_V()
        gwdcurrent.Rain1h = GetRainRate_V()
        gwdcurrent.WindSpeedMPH = GetWindSpeed_V()
        gwdcurrent.WindRDir = GetWindDir_V()
        gwdcurrent.WindDir = GetWindDirStr_V(sbWindDir).ToString ' This is where things go badly wrong
        gsngRainMTD = GetMonthlyRain_V()
    End If
    If gsnsSensor.IsUpToDate Then
        gwdcurrent.InHum = gsnsSensor.Humidity
        gwdcurrent.InTempF = gsnsSensor.TempF
    ElseIf tcHouse.Online Then
        gwdcurrent.InTempF = tcHouse.CurrentTemp
        gwdcurrent.InHum = tcHouse.CurrentHumidity
    End If
End Sub

AnswerRe: Accessing an external DLL from a Timer - should there be a problem? Pin
Dave Kreskowiak23-Apr-14 12:32
mveDave Kreskowiak23-Apr-14 12:32 
GeneralRe: Accessing an external DLL from a Timer - should there be a problem? Pin
Peter R. Fletcher23-Apr-14 12:48
Peter R. Fletcher23-Apr-14 12:48 
AnswerRe: Accessing an external DLL from a Timer - should there be a problem? Pin
Bernhard Hiller23-Apr-14 22:35
Bernhard Hiller23-Apr-14 22:35 
GeneralRe: Accessing an external DLL from a Timer - should there be a problem? Pin
Peter R. Fletcher24-Apr-14 3:17
Peter R. Fletcher24-Apr-14 3:17 
AnswerRe: Accessing an external DLL from a Timer - should there be a problem? Pin
Bernhard Hiller24-Apr-14 21:15
Bernhard Hiller24-Apr-14 21:15 
GeneralRe: Accessing an external DLL from a Timer - should there be a problem? Pin
Peter R. Fletcher25-Apr-14 5:49
Peter R. Fletcher25-Apr-14 5:49 
QuestionExcel VBA Macro ' Run-time error '9': Subscript out of range ' Pin
Deimantas23-Apr-14 0:53
Deimantas23-Apr-14 0:53 
AnswerRe: Excel VBA Macro ' Run-time error '9': Subscript out of range ' Pin
Richard Deeming23-Apr-14 1:23
mveRichard Deeming23-Apr-14 1:23 
GeneralRe: Excel VBA Macro ' Run-time error '9': Subscript out of range ' Pin
Deimantas23-Apr-14 1:33
Deimantas23-Apr-14 1:33 
GeneralRe: Excel VBA Macro ' Run-time error '9': Subscript out of range ' Pin
Richard Deeming23-Apr-14 1:38
mveRichard Deeming23-Apr-14 1:38 
GeneralRe: Excel VBA Macro ' Run-time error '9': Subscript out of range ' Pin
Deimantas25-Apr-14 8:45
Deimantas25-Apr-14 8:45 
QuestionVariable Question Pin
DJHJr21-Apr-14 4:33
DJHJr21-Apr-14 4:33 
AnswerRe: Variable Question Pin
Eddy Vluggen21-Apr-14 8:15
professionalEddy Vluggen21-Apr-14 8:15 
GeneralRe: Variable Question Pin
DJHJr21-Apr-14 10:10
DJHJr21-Apr-14 10:10 
GeneralRe: Variable Question Pin
Wes Aday21-Apr-14 11:47
professionalWes Aday21-Apr-14 11:47 
GeneralRe: Variable Question Pin
DJHJr21-Apr-14 13:09
DJHJr21-Apr-14 13:09 
GeneralRe: Variable Question Pin
Wes Aday21-Apr-14 13:14
professionalWes Aday21-Apr-14 13:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.